2017-05-09 00:21:19 +03:00
|
|
|
#!/usr/bin/env python
|
2020-11-16 11:30:39 +03:00
|
|
|
#
|
|
|
|
# Serving cheat.sh with `gevent`
|
|
|
|
#
|
2019-07-07 14:02:09 +03:00
|
|
|
|
2017-05-09 00:21:19 +03:00
|
|
|
from gevent.monkey import patch_all
|
2018-07-30 09:51:41 +03:00
|
|
|
from gevent.pywsgi import WSGIServer
|
2017-05-09 00:21:19 +03:00
|
|
|
patch_all()
|
|
|
|
|
|
|
|
import os
|
2020-11-16 11:30:39 +03:00
|
|
|
import sys
|
2017-05-09 00:21:19 +03:00
|
|
|
|
2020-11-16 11:30:39 +03:00
|
|
|
from app import app, CONFIG
|
2017-05-09 00:21:19 +03:00
|
|
|
|
2020-07-28 23:08:04 +03:00
|
|
|
|
2020-11-16 11:30:39 +03:00
|
|
|
if '--debug' in sys.argv:
|
|
|
|
# Not all debug mode features are available under `gevent`
|
|
|
|
# https://github.com/pallets/flask/issues/3825
|
|
|
|
app.debug = True
|
2020-11-04 07:48:54 +03:00
|
|
|
|
2020-11-16 11:30:39 +03:00
|
|
|
if 'CHEATSH_PORT' in os.environ:
|
|
|
|
port = int(os.environ.get('CHEATSH_PORT'))
|
|
|
|
else:
|
|
|
|
port = CONFIG['server.port']
|
2020-11-04 07:48:54 +03:00
|
|
|
|
2020-11-16 11:30:39 +03:00
|
|
|
srv = WSGIServer((CONFIG['server.bind'], port), app)
|
|
|
|
print("Starting gevent server on {}:{}".format(srv.address[0], srv.address[1]))
|
|
|
|
srv.serve_forever()
|