main.py 1.1 KB
Newer Older
1
import os
2
from flask import Flask, render_template
3
from flask_migrate import Migrate
4
5
from backend.database_config.database import DB
from backend.blueprints.project import project
6
from backend.blueprints.user import user
7
from backend.blueprints.todo import todo
8
from backend.blueprints.task import task
9

10
ENV = os.environ.get("ENV")
11

12
app = Flask(__name__)
13

14
app.register_blueprint(project)
15
app.register_blueprint(user)
16
app.register_blueprint(todo)
17
app.register_blueprint(task)
18
19
20

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

21
22
23
24
25
if ENV == 'dev':
    app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://g205001034_u:CierkbZMND@db.doc.ic.ac.uk:5432/g205001034_u'
else:
    app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://icbwsbzlctcxyx:a0d7f73e5b743a35f33d95640b517b6e7e9e5b59cd2ff10673e90372b4b34d44@ec2-34-193-112-164.compute-1.amazonaws.com:5432/deje5qriuvrh39'

26
27
db = DB.the_database

28
29
db.app = app
db.init_app(app)
30

31
32
migrate = Migrate(app, db)

33
@app.route("/")
34
def my_index():
35
    return render_template("index.html", token="DRP_token")
36

37

38
if __name__ == '__main__':
39
    app.run(debug=True, host='127.0.0.1', port=8080)