forked from JoeLim13/CaringApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
28 lines (21 loc) · 607 Bytes
/
app.py
File metadata and controls
28 lines (21 loc) · 607 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
import os
import config
from flask import Flask
from models.base_model import db
web_dir = os.path.join(os.path.dirname(
os.path.abspath(__file__)), 'caringapp_web')
app = Flask('CARINGAPP', root_path=web_dir)
app.secret_key = os.getenv("SECRET_KEY")
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