flask-libroro/app.py

40 lines
1.1 KiB
Python
Raw Normal View History

2025-02-20 09:50:47 +00:00
from flask import Flask, jsonify
from apis import api_system, api_auth, api_user, api_other
from apis.api_user import use_response_error
app = Flask(__name__)
# 注册蓝图
2025-02-21 09:53:37 +00:00
app.register_blueprint(api_system, url_prefix='/api/system')
app.register_blueprint(api_auth, url_prefix='/api/auth')
2025-02-20 09:50:47 +00:00
app.register_blueprint(api_user, url_prefix='/api/user')
2025-02-21 09:53:37 +00:00
app.register_blueprint(api_other, url_prefix='/api/other')
2025-02-20 09:50:47 +00:00
import logging
# 配置日志记录
logging.basicConfig(level=logging.DEBUG)
2025-02-21 09:53:37 +00:00
# @app.route("/api/user/info")
# def test():
# print("收到用户信息请求!")
# return "test"
# @app.route("/api/auth/login")
# def test2():
# print("收到登录请求!")
# return "test"
2025-02-20 09:50:47 +00:00
@app.errorhandler(404)
def page_not_found(e):
logging.error(f"404 Error: {e}")
return jsonify(use_response_error("Page not found", str(e))), 404
@app.errorhandler(Exception)
def internal_server_error(e):
logging.error(f"Internal Server Error: {e}", exc_info=True)
return jsonify(use_response_error("Internal Server Error", str(e))), 500
if __name__ == '__main__':
2025-02-21 09:53:37 +00:00
print("原神 启动!")
app.run(host="0.0.0.0",port=10300,debug=True)