잉여개발기 1 年之前
父节点
当前提交
013bf13631

+ 4 - 4
app.py

@@ -811,10 +811,10 @@ app.route('/api/thread/<int:topic_num>/<int:s_num>/<int:e_num>')(api_topic)
 app.route('/api/thread/<int:topic_num>/<tool>')(api_topic)
 app.route('/api/thread/<int:topic_num>')(api_topic)
 
-app.route('/api/search/<everything:name>')(api_func_search)
-app.route('/api/search_page/<int:num>/<everything:name>')(api_func_search)
-app.route('/api/search_data/<everything:name>', defaults = { 'search_type' : 'data' })(api_func_search)
-app.route('/api/search_data_page/<int:num>/<everything:name>', defaults = { 'search_type' : 'data' })(api_func_search)
+app.route('/api/search/<everything:name>')(api_func_search_exter)
+app.route('/api/search_page/<int:num>/<everything:name>')(api_func_search_exter)
+app.route('/api/search_data/<everything:name>', defaults = { 'search_type' : 'data' })(api_func_search_exter)
+app.route('/api/search_data_page/<int:num>/<everything:name>', defaults = { 'search_type' : 'data' })(api_func_search_exter)
 
 app.route('/api/recent_change')(api_list_recent_change)
 app.route('/api/recent_changes')(api_list_recent_change)

+ 6 - 7
route/__init__.py

@@ -186,16 +186,15 @@ from route.go_api_func_sha224 import api_func_sha224
 from route.go_api_func_ip import api_func_ip
 from route.go_api_func_ip_menu import api_func_ip_menu
 from route.go_api_func_auth import api_func_auth
-from route.go_api_func_email import api_func_email
-
-from route.go_api_func_search import api_func_search
+from route.go_api_func_email import api_func_email, api_func_email_exter
+from route.go_api_func_search import api_func_search, api_func_search_exter
 
 from route.go_api_give_auth import api_give_auth
 
 from route.go_api_list_recent_change import api_list_recent_change
 from route.go_api_list_recent_discuss import api_list_recent_discuss
 from route.go_api_list_recent_block import api_list_recent_block
-from route.go_api_list_recent_edit_request import api_list_recent_edit_request
+from route.go_api_list_recent_edit_request import api_list_recent_edit_request, api_list_recent_edit_request_exter
 from route.go_api_list_old_page import api_list_old_page
 from route.go_api_list_title_index import api_list_title_index
 from route.go_api_list_acl import api_list_acl
@@ -219,11 +218,11 @@ from route.go_api_topic_list import api_topic_list
 from route.go_api_user_rankup import api_user_rankup
 from route.go_api_user_setting_editor import api_user_setting_editor
 
-from route.go_api_w_raw import api_w_raw
-from route.go_api_w_random import api_w_random
+from route.go_api_w_raw import api_w_raw, api_w_raw_exter
+from route.go_api_w_random import api_w_random, api_w_random_exter
 from route.go_api_w_xref import api_w_xref
 from route.go_api_w_watch_list import api_w_watch_list
-from route.go_api_w_render import api_w_render
+from route.go_api_w_render import api_w_render, api_w_render_exter
 from route.go_api_w_set_reset import api_w_set_reset
 from route.go_api_w_page_view import api_w_page_view
 

+ 5 - 2
route/go_api_func_email.py

@@ -11,6 +11,9 @@ async def api_func_email():
         other_set["title"] = flask.request.form.get('title', '')
         other_set["data"] = flask.request.form.get('data', '')
 
-        return flask.Response(response = (await python_to_golang(func_name, other_set)), status = 200, mimetype = 'application/json')
+        return await python_to_golang(func_name, other_set)
     else:
-        return flask.jsonify({}) 
+        return {}
+
+async def api_func_email_exter():
+    return flask.Response(response = await api_func_email(), status = 200, mimetype = 'application/json')

+ 4 - 1
route/go_api_func_search.py

@@ -6,4 +6,7 @@ async def api_func_search(name = 'Test', search_type = 'title', num = 1):
     other_set["search_type"] = search_type
     other_set["num"] = str(num)
 
-    return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    return await python_to_golang(sys._getframe().f_code.co_name, other_set)
+
+async def api_func_search_exter(name = 'Test', search_type = 'title', num = 1):
+    return flask.Response(response = await api_func_search(name, search_type, num), status = 200, mimetype = 'application/json')

+ 4 - 1
route/go_api_list_recent_edit_request.py

@@ -7,4 +7,7 @@ async def api_list_recent_edit_request(num = 1, set_type = 'normal', limit = 50)
     other_set["set_type"] = set_type
     other_set["ip"] = ip_check()
 
-    return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    return await python_to_golang(sys._getframe().f_code.co_name, other_set)
+
+async def api_list_recent_edit_request_exter(num = 1, set_type = 'normal', limit = 50):
+    return flask.Response(response = await api_list_recent_edit_request_exter(num, set_type, limit), status = 200, mimetype = 'application/json')

+ 4 - 1
route/go_api_w_random.py

@@ -1,4 +1,7 @@
 from .tool.func import *
 
 async def api_w_random():
-    return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name)), status = 200, mimetype = 'application/json')
+    return await python_to_golang(sys._getframe().f_code.co_name)
+
+async def api_w_random_exter():
+    return flask.Response(response = await api_w_random(), status = 200, mimetype = 'application/json')

+ 4 - 1
route/go_api_w_raw.py

@@ -7,4 +7,7 @@ async def api_w_raw(name = 'Test', rev = '', exist_check = ''):
     other_set["exist_check"] = exist_check
     other_set["ip"] = ip_check()
 
-    return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    return await python_to_golang(sys._getframe().f_code.co_name, other_set)
+
+async def api_w_raw_exter(name = 'Test', rev = '', exist_check = ''):
+    return flask.Response(response = await api_w_raw(name, rev, exist_check), status = 200, mimetype = 'application/json')

+ 7 - 4
route/go_api_w_render.py

@@ -81,16 +81,19 @@ async def api_w_render(name = '', tool = '', request_method = '', request_data =
                     data_type = data_type
                 )
 
-                return flask.jsonify({
+                return {
                     "data" : data_pas[0], 
                     "js_data" : data_pas[1]
-                })
+                }
             else:
                 other_set = {}
                 other_set["doc_name"] = name
                 other_set["render_type"] = data_type
                 other_set["data"] = data_org
 
-                return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+                return await python_to_golang(sys._getframe().f_code.co_name, other_set)
         else:
-            return flask.jsonify({})
+            return {}
+
+async def api_w_render_exter(name = '', tool = '', request_method = '', request_data = {}):
+    return flask.Response(response = await api_w_render(name, tool, request_method, request_data), status = 200, mimetype = 'application/json')

+ 1 - 1
route/main_search_deep.py

@@ -51,7 +51,7 @@ async def main_search_deep(name = 'Test', search_type = 'title', num = 1):
                 <ul>
             '''
 
-            all_list = orjson.loads((await api_func_search(name, search_type, num)).get_data(as_text = True))
+            all_list = await api_func_search(name, search_type, num)
             for data in all_list:
                 div += '<li><a href="/w/' + url_pas(data) + '">' + data + '</a></li>'
 

+ 1 - 1
route/main_setting_email_test.py

@@ -8,7 +8,7 @@ async def main_setting_email_test():
             return re_error(conn, 0)
         
         if flask.request.method == 'POST':
-            render_data = json.loads((await api_func_email()).data)
+            render_data = await api_func_email()
             if render_data["response"] == "ok":
                 data = get_lang(conn, "ok")
             else:

+ 1 - 1
route/recent_edit_request.py

@@ -17,7 +17,7 @@ async def recent_edit_request():
                     </tr>
         '''
 
-        all_list = orjson.loads((await api_list_recent_edit_request()).get_data(as_text = True))
+        all_list = await api_list_recent_edit_request()
         for data in all_list:
             if re.search(r"\+", data[5]):
                 leng = '<span style="color:green;">(' + data[5] + ')</span>'

+ 2 - 2
route/tool/func.py

@@ -161,7 +161,7 @@ def python_to_golang_sync(func_name, other_set = {}):
 
         while 1:
             res = requests.post('http://localhost:' + db_data + '/', data = json.dumps(other_set))
-            data = res.text
+            data = res.json()
 
             if "error" == data:
                 raise
@@ -198,7 +198,7 @@ async def python_to_golang(func_name, other_set = {}):
         async with aiohttp.ClientSession() as session:
             while 1:
                 async with session.post('http://localhost:' + db_data + '/', data = json.dumps(other_set)) as res:
-                    data = await res.text()
+                    data = await res.json()
 
                     if "error" == data:
                         raise

+ 1 - 1
route/view_random.py

@@ -4,6 +4,6 @@ from .go_api_w_random import api_w_random
 
 async def view_random():
     with get_db_connect() as conn:
-        data = orjson.loads((await api_w_random()).get_data(as_text = True))["data"]
+        data = await api_w_random()["data"]
         
         return redirect(conn, '/w/' + url_pas(data))

+ 4 - 3
route/view_w.py

@@ -180,12 +180,13 @@ async def view_w(name = 'Test', do_type = ''):
 
             name_view = name
 
-        doc_data = json.loads((await api_w_raw(name)).data)
+        doc_data = await api_w_raw(name)
+        print(doc_data)
         if doc_data["response"] == "ok":
-            render_data = json.loads((await api_w_render(name, request_method = 'POST', request_data = {
+            render_data = await api_w_render(name, request_method = 'POST', request_data = {
                 'name' : name,
                 'data' : doc_data["data"]
-            })).data)
+            })
             end_data = render_data["data"] + '<script>document.addEventListener("DOMContentLoaded", function() {' + render_data["js_data"] + '});</script>'
         else:
             end_data = ''

+ 1 - 1
route/view_w_raw.py

@@ -14,7 +14,7 @@ async def view_w_raw(name = '', rev = '', doc_acl = ''):
         else:
             menu = [['w/' + url_pas(name), get_lang(conn, 'return')]]
 
-        data = json.loads((await api_w_raw(name, rev)).data)
+        data = await api_w_raw(name, rev)
         if data["response"] == "ok":
             data_in = data["data"]
         else: