-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
39 lines (30 loc) · 920 Bytes
/
config.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
from decouple import config
from flask import Flask
from flask_migrate import Migrate
from flask_restful import Api
from db import db
from resources.route import routes
class DevApplicationConfiguration:
DEBUG = True
TESTING = True
SQLALCHEMY_DATABASE_URI = (
f"postgresql://{config('DB_USER')}:{config('DB_PASSWORD')}"
f"@localhost:{config('DB_PORT')}/{config('DB_NAME')}"
)
class TestApplicationConfiguration:
DEBUG = True
TESTING = True
SQLALCHEMY_DATABASE_URI = (
f"postgresql://{config('DB_USER')}:{config('DB_PASSWORD')}"
f"@localhost:{config('DB_PORT')}/{config('TEST_DB_NAME')}"
)
def create_app(
config="config.DevApplicationConfiguration",
):
app = Flask(__name__)
db.init_app(app)
app.config.from_object(config)
migrate = Migrate(app, db)
api = Api(app)
[api.add_resource(*r) for r in routes]
return app