start.py 988 B

12345678910111213141516171819202122232425262728293031
  1. import os
  2. from app import create_app, db
  3. from flask import request, render_template, jsonify
  4. app = create_app(os.getenv('FLASK_CONFIG') or 'default')
  5. @app.errorhandler(404)
  6. def page_not_found(e):
  7. return render_template('errors/404.html'), 404
  8. @app.before_request
  9. def before():
  10. # print("请求地址:" + str(request.path))
  11. # print("请求方法:" + str(request.method))
  12. # print("---请求headers--start--")
  13. # print(str(request.headers).rstrip())
  14. # print("---请求headers--end----")
  15. # print("GET参数:" + str(request.args))
  16. # print("POST参数:" + str(request.form))
  17. url = request.path # 当前请求的URL
  18. passUrl = ["/login"]
  19. if url in passUrl:
  20. pass
  21. # else:
  22. # return jsonify({'msg': '当前操作没有权限', 'code': 403})
  23. # _id = session.get("_id", None)
  24. # if not _id:
  25. # return jsonify(401, {"msg": "认证失败,无法访问系统资源"})
  26. # else:
  27. # pass