Initial commit

This commit is contained in:
pbsds committed 2014-01-26 05:30:04 +01:00
commit a73140ee37
36 files changed
+4081

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
from twisted.web import resource
from twisted.internet import reactor
import time
from hatena import Database, ServerLog, Silent
from Hatenatools import TMB
#Handle flipnote uploads
class PyResource(resource.Resource):
isLeaf = True
def render_GET(self, request):
ServerLog.write("%s got 403 when requesting post/flipnote.post with GET" % (request.getClientIP()), Silent)
request.setResponseCode(405)
return "405 - Method Not Allowed"
def render_POST(self, request):#implement channels?
data = request.content.read()
channel = ""
if "channel" in request.args:
channel = request.args["channel"][0]
add = Database.AddFlipnote(data, channel)
if add:
ServerLog.write("%s successfully uploaded \"%s.ppm\"" % (request.getClientIP(), add[1]), Silent)
request.setResponseCode(200)
else:
ServerLog.write("%s tried to upload a flipnote, but failed..." % request.getClientIP(), Silent)
request.setResponseCode(500)#only causes an error, need to fix
return ""
#===