-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
55 lines (38 loc) · 1.29 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from flask import Flask, request
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
from flask_wtf.csrf import CSRFProtect
from datetime import timedelta
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address
from utilities.human_readable_date import human_readable_date
from celery import Celery
from dotenv import load_dotenv
from os import environ
app = Flask(__name__)
load_dotenv()
app.config['REMEMBER_COOKIE_DURATION'] = timedelta(hours=1)
app.config['SQLALCHEMY_DATABASE_URI'] = environ.get("DATABASE_URI")
app.config["broker_url"] = environ.get("REDIS_URL")
app.config["result_backend"] = environ.get("REDIS_URL")
db = SQLAlchemy(app)
app.jinja_env.globals.update(human_readable_date=human_readable_date)
celery = Celery(app.name, broker=app.config["broker_url"])
celery.conf.update(app.config)
limiter = Limiter(
key_func=get_remote_address,
app=app,
storage_uri=environ.get("REDIS_URL"),
)
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'
app.secret_key = environ.get("SECRET_KEY")
csrf = CSRFProtect(app)
from application.models import Users
from application import views
with app.app_context():
#db.drop_all()
db.create_all()
if __name__ == '__main__':
app.run()