import logging from flask import Flask import route.upload, route.analyze, route.result from config import VERSION_PREFIX, MAX_CONTENT_LENGTH, MYSQL_URI from route.util import make_response from db import db app = Flask(__name__) app.config['MAX_CONTENT_LENGTH'] = MAX_CONTENT_LENGTH app.config['SQLALCHEMY_DATABASE_URI'] = MYSQL_URI app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.register_blueprint(route.upload.bp, url_prefix=VERSION_PREFIX) app.register_blueprint(route.analyze.bp, url_prefix=VERSION_PREFIX) app.register_blueprint(route.result.bp, url_prefix=VERSION_PREFIX) db.init_app(app) with app.app_context(): # db.drop_all() db.create_all() @app.route("/") def hello_world(): return "
Hello, World!
" @app.errorhandler(413) def error_handler(e): logging.exception(e) return make_response(413, "entity too large, max acceptable: " + str(MAX_CONTENT_LENGTH) + " bytes", {}) @app.errorhandler(404) def error_handler(e): logging.exception(e) return make_response(404, "path not found.", {}) @app.errorhandler(Exception) def error_handler(e): logging.exception(e) return make_response(500, "unknown internal server error.", {}) if __name__ == '__main__': app.run()