Archived
修改了返回静态文件方式, 修改前的状态码为302 修改后为200
This commit is contained in:
5 files changed
+216
-217
No files matched your search
@@ -12,14 +12,13 @@ from flask import Flask
|
|||||||
from flask import request
|
from flask import request
|
||||||
from flask import Response
|
from flask import Response
|
||||||
from flask import make_response
|
from flask import make_response
|
||||||
from flask import send_from_directory
|
|
||||||
from flask import jsonify
|
from flask import jsonify
|
||||||
from bin.core.error import ErrorProcess
|
from bin.utils.error import ErrorProcess
|
||||||
from bin.core.render_ import render_temp_
|
from bin.utils.render_ import render_temp_
|
||||||
from bin.core.b64img import re_sort_number_image
|
from bin.utils.b64img import re_sort_number_image
|
||||||
from db.db import fetch_data
|
from db.db import fetch_data
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__, static_url_path='')
|
||||||
app.config['JSON_SORT_KEYS'] = False # 设置JSON消息不根据字母顺序重新排序
|
app.config['JSON_SORT_KEYS'] = False # 设置JSON消息不根据字母顺序重新排序
|
||||||
app.config['JSON_AS_ASCII'] = False # 设置JSON消息显示中文
|
app.config['JSON_AS_ASCII'] = False # 设置JSON消息显示中文
|
||||||
|
|
||||||
@@ -31,7 +30,7 @@ def miss(reason) -> Response:
|
|||||||
:param reason:
|
:param reason:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
return jsonify({'code': 404, 'msg': f'{reason}', 'data': []})
|
return jsonify({'code': 404, 'msg': f'{reason}', 'data': None})
|
||||||
|
|
||||||
|
|
||||||
@app.errorhandler(500)
|
@app.errorhandler(500)
|
||||||
@@ -41,16 +40,7 @@ def error(reason) -> Response:
|
|||||||
:param reason:
|
:param reason:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
return jsonify({'code': 500, 'msg': f'{reason}', 'data': []})
|
return jsonify({'code': 500, 'msg': f'{reason}', 'data': None})
|
||||||
|
|
||||||
|
|
||||||
@app.route('/favicon.ico', methods=['GET', 'POST'])
|
|
||||||
def favicon() -> Response:
|
|
||||||
"""
|
|
||||||
主页图标
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return app.send_static_file('favicon.ico')
|
|
||||||
|
|
||||||
|
|
||||||
def build_page(name: str, length: int, theme: str) -> list[bool or Response] or list[bool or str] or bool:
|
def build_page(name: str, length: int, theme: str) -> list[bool or Response] or list[bool or str] or bool:
|
||||||
@@ -111,13 +101,22 @@ def api_page() -> Response or str:
|
|||||||
return ErrorProcess().arg_not_be_full()
|
return ErrorProcess().arg_not_be_full()
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/favicon.ico', methods=['GET', 'POST'])
|
||||||
|
def favicon() -> Response:
|
||||||
|
"""
|
||||||
|
主页图标
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return app.send_static_file('favicon.ico')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/', methods=['GET', 'POST'])
|
@app.route('/', methods=['GET', 'POST'])
|
||||||
def index() -> Response:
|
def index() -> Response:
|
||||||
"""
|
"""
|
||||||
索引页面
|
索引页面
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
return send_from_directory('./static', 'index.html')
|
return app.send_static_file('index.html')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in New Issue
Block a user