diff --git a/src/apiservers/private/register_private_blueprints.py b/src/apiservers/private/register_private_blueprints.py
index 0a33a8dd..d3abcbd0 100644
--- a/src/apiservers/private/register_private_blueprints.py
+++ b/src/apiservers/private/register_private_blueprints.py
@@ -10,20 +10,20 @@ from httpapi import miscclientapi, onionrsitesapi, apiutils
from httpapi import themeapi
from httpapi import fileoffsetreader
from httpapi.sse.private import private_sse_blueprint
-
+from httpapi.serializedapi import serialized_api_bp
"""
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
"""
@@ -44,6 +44,7 @@ def register_private_blueprints(private_api, app):
app.register_blueprint(themeapi.theme_blueprint)
app.register_blueprint(private_sse_blueprint)
app.register_blueprint(fileoffsetreader.offset_reader_api)
+ app.register_blueprint(serialized_api_bp)
def _add_events_bp():
while True:
diff --git a/src/httpapi/serializedapi/__init__.py b/src/httpapi/serializedapi/__init__.py
index 01cdea56..2866eb7c 100644
--- a/src/httpapi/serializedapi/__init__.py
+++ b/src/httpapi/serializedapi/__init__.py
@@ -3,7 +3,7 @@
view and interact with onionr sites
"""
from flask import Blueprint, Response, request, abort, g
-import ujson as json
+import json
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -32,15 +32,29 @@ def serialized(name: str) -> Response:
attr = getattr(initial, i)
if callable(attr):
- data = json.loads(request.get_json(force=True))
- args = data['args']
- del data['args']
+ try:
+ js = request.get_json(force=True)
+ print('json', js, type(js))
+ data = json.loads(js)
+ args = data['args']
+ del data['args']
+ except (TypeError, ValueError) as e:
+ print(repr(e))
+ data = {}
+ args = []
+ print('data', data)
if data:
print(*args, **data)
- return Response(attr(*args, **data))
+ resp = attr(*args, **data)
+ if isinstance(resp, int):
+ resp = str(resp)
+ return Response(resp)
else:
print(*args, **data)
- return Response(attr(*args))
+ resp = attr(*args)
+ if isinstance(resp, int):
+ resp = str(resp)
+ return Response(resp, content_type='application/octet-stream')
else:
if isinstance(attr, int):
attr = str(attr)