forked from NextAcademy/curriculum-nextagram-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
45 lines (33 loc) · 942 Bytes
/
app.py
File metadata and controls
45 lines (33 loc) · 942 Bytes
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
from flask_wtf.csrf import CSRFProtect
import os
import config
from flask import Flask
from models.base_model import db
from flask_socketio import SocketIO, emit
# import logging
# import redis
# import gevent
# from flask_sockets import Sockets
# REDIS_URL = os.environ['REDIS_URL']
# REDIS_CHAN = 'chat'
# app.debug = 'DEBUG' in os.environ
# sockets = Sockets(app)
# redis = redis.from_url(REDIS_URL)
web_dir = os.path.join(os.path.dirname(
os.path.abspath(__file__)), 'instagram_web')
app = Flask('NEXTAGRAM', root_path=web_dir)
csrf = CSRFProtect(app)
socketio = SocketIO(app)
if os.getenv('FLASK_ENV') == 'production':
app.config.from_object("config.ProductionConfig")
else:
app.config.from_object("config.DevelopmentConfig")
@app.before_request
def before_request():
db.connect()
@app.teardown_request
def _db_close(exc):
if not db.is_closed():
print(db)
print(db.close())
return exc