-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
47 lines (39 loc) · 1.36 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
from flask import Flask
from flask_restful import Api
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_marshmallow import Marshmallow
from flask_jwt_extended import JWTManager
from flask_cors import CORS
from flasgger import Swagger
from decouple import config
from resources import add_resources
app = Flask(__name__)
CORS(app)
app.config.update(
DEBUG=config('FLASK_DEBUG', default=False, cast=bool),
TESTING=config('FLASK_TESTING', default=False, cast=bool),
ENV=config('FLASK_ENV', default='production'),
JWT_TOKEN_LOCATION=['headers'],
JWT_ACCESS_TOKEN_EXPIRES=20,
JWT_REFRESH_TOKEN_EXPIRES=1800,
JWT_HEADER_NAME='Authorization',
JWT_HEADER_TYPE='Bearer',
JWT_SECRET_KEY=config('JWT_SECRET_KEY'),
SQLALCHEMY_TRACK_MODIFICATIONS=True,
SQLALCHEMY_DATABASE_URI=f""
f"postgres://"
f"{config('DB_USER')}:"
f"{config('DB_PASSWORD')}@"
f"{config('DB_HOST')}:"
f"{config('DB_PORT', cast=int)}/"
f"{config('DB_NAME')}?client_encoding=utf8"
)
api = Api(app, prefix='/api/v1')
db = SQLAlchemy(app)
ma = Marshmallow(app)
migrate = Migrate(app, db)
jwt = JWTManager(app)
swagger = Swagger(app)
add_resources(api)
from models import * # noqa F401