-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
49 lines (42 loc) · 1.21 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
from flask import Flask
from flask_caching import Cache
from flask_sqlalchemy import SQLAlchemy
from flask_wtf import CSRFProtect
from os import environ
from sqlalchemy.ext.declarative import declarative_base
app = Flask(__name__)
cache = Cache()
cache.init_app(
app=app,
config={
"CACHE_TYPE": "memcached",
'tcp_nodelay': True,
'tcp_keepalive': True,
'connect_timeout': 2000,
'send_timeout': 750 * 1000,
'receive_timeout': 750 * 1000,
'_poll_timeout': 2000,
'ketama': True,
'remove_failed': 1,
'retry_timeout': 2,
'dead_timeout': 30
}
)
app.config['SECRET_KEY'] = environ['SECRET_KEY']
app.config[
'SQLALCHEMY_DATABASE_URI'] = f"mysql+pymysql://{environ['DB_USER']}:{environ['DB_PASSWORD']}@{environ['DB_HOST']}/{environ['DB_NAME']}"
app.config['SQLALCHEMY_POOL_SIZE'] = 20
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_ENGINE_OPTIONS'] = {
'pool_pre_ping': True,
'pool_recycle': 1
}
# Database Connect
db = SQLAlchemy(app=app)
dbEngine = db.engine
dbBase = declarative_base(dbEngine)
# protecting our app
csrf = CSRFProtect(app)
from route import *
if __name__ == '__main__':
app.run()