nova-web/web/app.py

65 lines
1.6 KiB
Python
Raw Normal View History

2023-07-25 03:38:53 +02:00
import os
import flask
import secrets
import logging
from dotenv import load_dotenv
from werkzeug.middleware.proxy_fix import ProxyFix
load_dotenv()
log = logging.getLogger('werkzeug')
log.disabled = True
def create_app() -> flask.Flask:
app = flask.Flask(__name__)
2023-08-29 21:02:50 +02:00
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1)
app.secret_key = os.environ['FLASK_SECRET_KEY']
2023-09-14 22:42:12 +02:00
app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True
2023-07-25 03:38:53 +02:00
2023-08-27 18:10:10 +02:00
import tos
2023-09-14 22:42:12 +02:00
import account
2023-09-22 01:00:00 +02:00
import finances
2023-09-14 22:42:12 +02:00
2023-08-27 18:10:10 +02:00
tos.register(app)
2023-09-14 22:42:12 +02:00
account.register(app)
2023-09-22 01:00:00 +02:00
finances.register(app)
2023-09-14 22:42:12 +02:00
2023-10-12 00:07:30 +02:00
# max file size 100 MB (cloudflare limit)
2023-09-14 22:42:12 +02:00
app.config['MAX_CONTENT_LENGTH'] = 100 * 1024 * 1024
2023-08-27 18:10:10 +02:00
2023-07-25 03:38:53 +02:00
@app.context_processor
def inject_variables():
return {
'contact_email': os.getenv('CONTACT_EMAIL')
}
@app.route('/')
def index():
return flask.render_template('index.html')
2023-09-14 22:42:12 +02:00
@app.route('/get-started')
2023-08-20 13:41:24 +02:00
def go():
2023-09-14 22:42:12 +02:00
return flask.render_template('get-started.html')
2023-07-25 03:38:53 +02:00
@app.route('/novacord')
2023-08-20 13:41:24 +02:00
def novacord_page():
2023-07-25 03:38:53 +02:00
return flask.render_template('novacord.html')
2023-08-20 13:41:24 +02:00
@app.route('/replit')
def replit_page():
return flask.render_template('replit.html')
2023-07-25 03:38:53 +02:00
@app.route('/favicon.ico')
def favicon():
return flask.send_file('static/img/fav.ico', mimetype='image/vnd.microsoft.icon')
return app
production = create_app()
if __name__ == '__main__':
print('* DEV environment online at http://localhost:2211')
2023-08-29 21:02:50 +02:00
create_app().run(debug=True, use_reloader=True, use_evalex=False, port=2211, host='0.0.0.0', threaded=True)