app.py 868 B

12345678910111213141516171819202122232425262728293031323334353637
  1. from concurrent.futures import ThreadPoolExecutor
  2. import logging
  3. from flask import Flask
  4. import route.upload
  5. from config import VERSION_PREFIX, MAX_CONTENT_LENGTH
  6. from route.util import make_response
  7. app = Flask(__name__)
  8. app.config['MAX_CONTENT_LENGTH'] = MAX_CONTENT_LENGTH
  9. pool = ThreadPoolExecutor(max_workers=2)
  10. @app.route("/")
  11. def hello_world():
  12. return "<p>Hello, World!</p>"
  13. app.register_blueprint(route.upload.bp, url_prefix=VERSION_PREFIX)
  14. @app.errorhandler(413)
  15. def error_handler(e):
  16. logging.exception(e)
  17. return make_response(413, "entity too large, max acceptable: " + str(MAX_CONTENT_LENGTH) + " bytes", {})
  18. @app.errorhandler(Exception)
  19. def error_handler(e):
  20. logging.exception(e)
  21. return make_response(500, "unknown internal server error.", {})
  22. if __name__ == '__main__':
  23. app.run()