Browse Source

코드 수정

잉여개발기 1 year ago
parent
commit
4a15cde578

+ 7 - 1
app.py

@@ -421,7 +421,13 @@ def auto_do_something(data_db_set):
     if data_db_set['type'] == 'sqlite':
         back_up(data_db_set)
 
-    do_every_day()
+    try:
+        loop = asyncio.get_running_loop()
+        loop.create_task(do_every_day())
+    except RuntimeError:
+        loop = asyncio.new_event_loop()
+        asyncio.set_event_loop(loop)
+        loop.run_until_complete(do_every_day())
 
 auto_do_something(data_db_set)
 

+ 1 - 1
route/go_api_bbs.py

@@ -6,4 +6,4 @@ async def api_bbs(bbs_num = "", page = 1):
     other_set["page"] = str(page)
     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 flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 1
route/go_api_bbs_list.py

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

+ 1 - 1
route/go_api_bbs_w.py

@@ -9,4 +9,4 @@ async def api_bbs_w(sub_code = '', legacy = 'on'):
     return await python_to_golang(sys._getframe().f_code.co_name, other_set)
 
 async def api_bbs_w_exter(sub_code = '', legacy = 'on'):
-    return flask.Response(response = await api_bbs_w(sub_code, legacy), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await api_bbs_w(sub_code, legacy))

+ 1 - 1
route/go_api_bbs_w_comment.py

@@ -10,4 +10,4 @@ async def api_bbs_w_comment(sub_code = '', tool = "", legacy = 'on'):
     return await python_to_golang(sys._getframe().f_code.co_name, other_set)
 
 async def api_bbs_w_comment_exter(sub_code = '', tool = "", legacy = 'on'):
-    return flask.Response(response = await api_bbs_w_comment(sub_code, tool, legacy), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await api_bbs_w_comment(sub_code, tool, legacy))

+ 1 - 1
route/go_api_bbs_w_comment_one.py

@@ -10,4 +10,4 @@ async def api_bbs_w_comment_one(sub_code = '', legacy = 'on', tool = ''):
     return await python_to_golang(sys._getframe().f_code.co_name, other_set)
 
 async def api_bbs_w_comment_one_exter(sub_code = '', legacy = 'on', tool = ''):
-    return flask.Response(response = await api_bbs_w_comment_one(sub_code, legacy, tool), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await api_bbs_w_comment_one(sub_code, legacy, tool))

+ 1 - 1
route/go_api_bbs_w_set.py

@@ -11,4 +11,4 @@ async def api_bbs_w_set(name = 'Test', bbs_num = 1):
         func_name += '_put'
         other_set['data'] = flask.request.form.get('data', 'Test')
     
-    return flask.Response(response = (await python_to_golang(func_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(func_name, other_set))

+ 1 - 1
route/go_api_bbs_w_tabom.py

@@ -9,4 +9,4 @@ async def api_bbs_w_tabom(sub_code = ''):
     if flask.request.method == 'POST':
         func_name += '_post'
 
-    return flask.Response(response = (await python_to_golang(func_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(func_name, other_set))

+ 1 - 1
route/go_api_func_auth.py

@@ -4,4 +4,4 @@ async def api_func_auth(user_name = ''):
     other_set = {}
     other_set["ip"] = ip_check() if user_name == '' else user_name
 
-    return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 1
route/go_api_func_email.py

@@ -16,4 +16,4 @@ async def api_func_email():
         return {}
 
 async def api_func_email_exter():
-    return flask.Response(response = await api_func_email(), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await api_func_email())

+ 1 - 1
route/go_api_func_ip.py

@@ -21,4 +21,4 @@ async def api_func_ip(data = 'Test'):
     else:
         other_set["data"] = data
 
-    return flask.Response(response = (await python_to_golang(func_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(func_name, other_set))

+ 1 - 1
route/go_api_func_ip_menu.py

@@ -6,4 +6,4 @@ async def api_func_ip_menu(ip = "Test", option = ""):
     other_set["my_ip"] = ip_check()
     other_set["option"] = option
 
-    return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 1
route/go_api_func_language.py

@@ -10,4 +10,4 @@ async def api_func_language(legacy = 'on', data = 'Test'):
 
     other_set["legacy"] = legacy
 
-    return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 1
route/go_api_func_llm.py

@@ -6,6 +6,6 @@ async def api_func_llm():
         other_set["prompt"] = flask.request.form.get('prompt', '')
         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 flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))
     else:
         return flask.jsonify({})

+ 1 - 1
route/go_api_func_search.py

@@ -9,4 +9,4 @@ async def api_func_search(name = 'Test', search_type = 'title', num = 1):
     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')
+    return flask.jsonify(await api_func_search(name, search_type, num))

+ 1 - 1
route/go_api_func_sha224.py

@@ -4,4 +4,4 @@ async def api_func_sha224(data = 'Test'):
     other_set = {}
     other_set["data"] = data
 
-    return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 1
route/go_api_give_auth.py

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

+ 1 - 1
route/go_api_list_acl.py

@@ -4,4 +4,4 @@ async def api_list_acl(data_type = ''):
     other_set = {}
     other_set = data_type
 
-    return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 1
route/go_api_list_auth.py

@@ -3,4 +3,4 @@ from .tool.func import *
 async def api_list_auth():
     other_set = {}
 
-    return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 1
route/go_api_list_history.py

@@ -7,4 +7,4 @@ async def api_list_history(num = 1, set_type = 'normal', doc_name = 'Test'):
     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 flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 3
route/go_api_list_markup.py

@@ -1,6 +1,4 @@
 from .tool.func import *
 
 async def api_list_markup():
-    other_set = {}
-
-    return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name))

+ 1 - 1
route/go_api_list_old_page.py

@@ -5,4 +5,4 @@ async def api_list_old_page(num = 1, set_type = 'old'):
     other_set["num"] = str(num)
     other_set["set_type"] = set_type
     
-    return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 1
route/go_api_list_recent_block.py

@@ -8,4 +8,4 @@ async def api_list_recent_block(num = 1, set_type = 'all', user_name = 'Test', w
     other_set["why"] = why
     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 flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 1
route/go_api_list_recent_change.py

@@ -8,7 +8,7 @@ async def api_list_recent_change(num = 1, set_type = 'normal', limit = 10, legac
     other_set["legacy"] = legacy
     other_set["ip"] = ip_check()
 
-    response = flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    response = flask.make_response(flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set)))
     
     response.headers.add("Access-Control-Allow-Origin", "*")
     response.headers.add('Access-Control-Allow-Headers', "Content-Type")

+ 1 - 1
route/go_api_list_recent_discuss.py

@@ -8,7 +8,7 @@ async def api_list_recent_discuss(num = 1, set_type = 'normal', limit = 10, lega
     other_set["legacy"] = legacy
     other_set["ip"] = ip_check()
 
-    response = flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    response = flask.make_response(flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set)))
     
     response.headers.add("Access-Control-Allow-Origin", "*")
     response.headers.add('Access-Control-Allow-Headers', "Content-Type")

+ 1 - 1
route/go_api_list_recent_edit_request.py

@@ -10,4 +10,4 @@ async def api_list_recent_edit_request(num = 1, set_type = 'normal', limit = 50)
     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')
+    return flask.jsonify(await api_list_recent_edit_request_exter(num, set_type, limit))

+ 1 - 1
route/go_api_list_title_index.py

@@ -4,4 +4,4 @@ async def api_list_title_index(num = 1):
     other_set = {}
     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 flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 1
route/go_api_setting.py

@@ -10,4 +10,4 @@ async def api_setting(name = 'Test'):
         func_name += '_put'
         other_set['data'] = flask.request.form.get('data', 'Test')
     
-    return flask.Response(response = (await python_to_golang(func_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(func_name, other_set))

+ 1 - 1
route/go_api_topic.py

@@ -132,6 +132,6 @@ async def api_topic(topic_num = 1, tool = 'normal', s_num = '', e_num = ''):
             other_set["e_num"] = str(e_num)
             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 flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))
         else:
             return flask.jsonify({})

+ 1 - 1
route/go_api_topic_list.py

@@ -6,4 +6,4 @@ async def api_topic_list(name = 'Test', set_type = 'normal', num = 1):
     other_set["set_type"] = set_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 flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 1
route/go_api_user_rankup.py

@@ -8,4 +8,4 @@ async def api_user_rankup():
     if flask.request.method == 'PATCH':
         func_name += '_patch'
 
-    return flask.Response(response = (await python_to_golang(func_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(func_name, other_set))

+ 1 - 1
route/go_api_user_setting_editor.py

@@ -12,4 +12,4 @@ async def api_user_setting_editor():
         func_name += '_delete'
         other_set['data'] = flask.request.form.get('data', 'Test')
 
-    return flask.Response(response = (await python_to_golang(func_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(func_name, other_set))

+ 1 - 1
route/go_api_w_page_view.py

@@ -4,4 +4,4 @@ async def api_w_page_view(name = 'Test'):
     other_set = {}
     other_set["doc_name"] = name
 
-    return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 1
route/go_api_w_random.py

@@ -4,4 +4,4 @@ async def api_w_random():
     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')
+    return flask.jsonify(await api_w_random())

+ 1 - 1
route/go_api_w_raw.py

@@ -10,4 +10,4 @@ async def api_w_raw(name = 'Test', rev = '', exist_check = ''):
     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')
+    return flask.jsonify(await api_w_raw(name, rev, exist_check))

+ 1 - 1
route/go_api_w_render.py

@@ -96,4 +96,4 @@ async def api_w_render(name = '', tool = '', request_method = '', request_data =
             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')
+    return flask.jsonify(await api_w_render(name, tool, request_method, request_data))

+ 1 - 1
route/go_api_w_set_reset.py

@@ -5,4 +5,4 @@ async def api_w_set_reset(name = 'Test'):
     other_set["name"] = name
     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 flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 1
route/go_api_w_watch_list.py

@@ -7,4 +7,4 @@ async def api_w_watch_list(name = 'Test', do_type = 'watch_list', num = 1):
     other_set["ip"] = ip_check()
     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 flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))

+ 1 - 1
route/go_api_w_xref.py

@@ -6,4 +6,4 @@ async def api_w_xref(name = 'Test', page = 1, xref_type = '1'):
     other_set["page"] = str(page)
     other_set["do_type"] = xref_type
 
-    return flask.Response(response = (await python_to_golang(sys._getframe().f_code.co_name, other_set)), status = 200, mimetype = 'application/json')
+    return flask.jsonify(await python_to_golang(sys._getframe().f_code.co_name, other_set))