Files
RexiMemo-OSE/hatenadir/ds/v2-xx/post/flipnote.post.py
T
Rekushi e4bb0b00ba 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
2026-08-31 20:33:10 +01:00

26 lines
933 B
Python

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""