2020-05-25 03:09:12 +00:00
|
|
|
from werkzeug.exceptions import NotFound
|
|
|
|
from werkzeug.middleware.dispatcher import DispatcherMiddleware
|
|
|
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
|
|
|
|
|
|
|
from crc import app
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
def no_app(environ, start_response):
|
|
|
|
return NotFound()(environ, start_response)
|
|
|
|
|
|
|
|
# Remove trailing slash, but add leading slash
|
|
|
|
base_url = '/' + app.config['APPLICATION_ROOT'].strip('/')
|
2020-05-25 15:41:53 +00:00
|
|
|
routes = {'/': app.wsgi_app}
|
|
|
|
|
|
|
|
if base_url != '/':
|
|
|
|
routes[base_url] = app.wsgi_app
|
2020-05-25 03:09:12 +00:00
|
|
|
|
2020-05-25 15:41:53 +00:00
|
|
|
app.wsgi_app = DispatcherMiddleware(no_app, routes)
|
2020-05-25 03:09:12 +00:00
|
|
|
app.wsgi_app = ProxyFix(app.wsgi_app)
|
|
|
|
|
|
|
|
flask_port = app.config['FLASK_PORT']
|
|
|
|
|
|
|
|
app.run(host='0.0.0.0', port=flask_port)
|