This commit is contained in:
Victor Ng 2019-02-20 13:12:39 -05:00
Родитель 2f6c63f718
Коммит b8e9956693
1 изменённых файлов: 28 добавлений и 22 удалений

Просмотреть файл

@ -16,7 +16,9 @@ app = Flask(__name__)
dockerflow = Dockerflow(app)
# Hook the application plugin and configure it
PLUGIN = config('TAAR_API_PLUGIN', default=None)
PLUGIN = config("TAAR_API_PLUGIN", default=None)
sentry_sdk.init(
dsn=config("SENTRY_DSN"),
integrations=[FlaskIntegration()],
@ -44,23 +46,31 @@ def flaskrun(app, default_host="127.0.0.1", default_port="8000"):
# Set up the command-line options
parser = optparse.OptionParser()
parser.add_option("-H", "--host",
help="Hostname of the Flask app " +
"[default %s]" % default_host,
default=default_host)
parser.add_option("-P", "--port",
help="Port for the Flask app " +
"[default %s]" % default_port,
default=default_port)
parser.add_option(
"-H",
"--host",
help="Hostname of the Flask app " + "[default %s]" % default_host,
default=default_host,
)
parser.add_option(
"-P",
"--port",
help="Port for the Flask app " + "[default %s]" % default_port,
default=default_port,
)
# Two options useful for debugging purposes, but
# a bit dangerous so not exposed in the help message.
parser.add_option("-d", "--debug",
action="store_true", dest="debug",
help=optparse.SUPPRESS_HELP)
parser.add_option("-p", "--profile",
action="store_true", dest="profile",
help=optparse.SUPPRESS_HELP)
parser.add_option(
"-d", "--debug", action="store_true", dest="debug", help=optparse.SUPPRESS_HELP
)
parser.add_option(
"-p",
"--profile",
action="store_true",
dest="profile",
help=optparse.SUPPRESS_HELP,
)
options, _ = parser.parse_args()
@ -69,16 +79,12 @@ def flaskrun(app, default_host="127.0.0.1", default_port="8000"):
if options.profile:
from werkzeug.contrib.profiler import ProfilerMiddleware
app.config['PROFILE'] = True
app.config["PROFILE"] = True
app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30])
options.debug = True
app.run(
debug=options.debug,
host=options.host,
port=int(options.port)
)
app.run(debug=options.debug, host=options.host, port=int(options.port))
if __name__ == '__main__':
if __name__ == "__main__":
flaskrun(app)