-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinfra.py
29 lines (21 loc) · 777 Bytes
/
infra.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
import os
from dotenv import load_dotenv
import logging
from src.models import migrate, db
from flask import Flask
ENV_FILE_PATH = './.env'
app = Flask(__name__)
dotenv_path = ENV_FILE_PATH
# Load .env file and if .env file is not found then will use system environment variables
load_dotenv(dotenv_path, override=True)
app.config.from_envvar('FLASK_CONFIG_FILE_PATH')
conf = app.config
from src.apis import register_api
register_api()
if not app.debug:
logging.getLogger(app.name).addHandler(logging.StreamHandler())
logging.getLogger(app.name).setLevel(logging.INFO)
db.init_app(app)
migrate.init_app(app, db, directory=os.environ['MIGRATION_FOLDER_PATH'])
logging.basicConfig(format=conf.get('LOG_FORMAT'))
logging.getLogger().setLevel(conf.get('LOG_LEVEL'))