feat: port Hatena server to Python 3
* Update server-side database and dynamic resource code for Python 3 * Preserve existing Flipnote, UGO, NTFT, CSS, localization, and Hatena assets * Port Flipnote upload and movie endpoints * Update front page UGO menu generators * Preserve existing database and sample Flipnote data * Add regression tests for database operations and binary formats * Add server resource loading tests * Maintain compatibility with the original DSi Flipnote Studio protocol
This commit is contained in:
1 parent
687a2bcb43
commit
e4bb0b00ba
48 files changed
+3463
No files matched your search
@@ -0,0 +1,25 @@
|
||||
from twisted.web import resource
|
||||
|
||||
from hatena import ServerLog, Silent, request_args, client_ip
|
||||
from DB import Database
|
||||
|
||||
|
||||
class PyResource(resource.Resource):
|
||||
isLeaf = True
|
||||
|
||||
def render_GET(self, request):
|
||||
ServerLog.write("%s got 403 when requesting post/flipnote.post with GET" % client_ip(request), Silent)
|
||||
request.setResponseCode(405)
|
||||
return b"405 - Method Not Allowed"
|
||||
|
||||
def render_POST(self, request):
|
||||
data = request.content.read()
|
||||
channel = request_args(request).get("channel", [""])[0]
|
||||
add = Database.AddFlipnote(data, channel)
|
||||
if add:
|
||||
ServerLog.write('%s successfully uploaded "%s.ppm"' % (client_ip(request), add[1]), Silent)
|
||||
request.setResponseCode(200)
|
||||
else:
|
||||
ServerLog.write("%s tried to upload a flipnote, but failed..." % client_ip(request), Silent)
|
||||
request.setResponseCode(500)
|
||||
return b""
|
||||
Reference in new issue
Block a user
