1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 14:34:19 +00:00
pds-2021-g2-nest/code/backend/nest_backend/__main__.py

27 lines
726 B
Python
Raw Normal View History

"""
This is the runner for the server.
"""
2021-04-19 14:14:51 +00:00
from flask import Flask
import os
import werkzeug.middleware.proxy_fix
2021-04-19 14:23:50 +00:00
from .routes import *
from database import Base, tables
import psycopg2
2021-04-19 14:14:51 +00:00
app = Flask(__name__)
if os.getenv('COOKIE_SECRET'):
app.secret_key = os.getenv('COOKIE_SECRET')
else:
app.secret_key = "testing"
reverse_proxy_app = werkzeug.middleware.proxy_fix.ProxyFix(app=app, x_for=1, x_proto=0, x_host=1, x_port=0, x_prefix=0)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:password@localhost:5432/PdSDev'
Base.app = app
Base.init_app(app)
2021-04-19 14:14:51 +00:00
# Routes setup
2021-04-19 14:23:50 +00:00
app.add_url_rule("/doa", view_func=page_doa, methods=["GET"])
2021-04-19 14:14:51 +00:00
if __name__ == "__main__":
Base.create_all()
2021-04-19 14:14:51 +00:00
app.run(debug=True)