-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
49 lines (40 loc) · 1.19 KB
/
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
40
41
42
43
44
45
46
47
48
49
from decouple import config
from flask import Flask
from flask_cors import CORS
from flask_migrate import Migrate
from flask_restful import Api
from db import db
from resources.routes import *
class ProductionConfig:
FLASK_ENV = "prod"
DEBUG = False
TESTING = False
SQLALCHEMY_DATABASE_URI = (
f"postgresql://{config('DB_USER')}:{config('DB_PASSWORD')}"
f"@localhost:{config('DB_PORT')}/{config('DB_NAME')}"
)
class DevelopmentConfig:
FLASK_ENV = "development"
DEBUG = True
TESTING = True
SQLALCHEMY_DATABASE_URI = (
f"postgresql://{config('DB_USER')}:{config('DB_PASSWORD')}"
f"@localhost:{config('DB_PORT')}/{config('DB_NAME')}"
)
class TestingConfig:
FLASK_ENV = "testing"
DEBUG = True
TESTING = True
SQLALCHEMY_DATABASE_URI = (
f"postgresql://{config('TEST_DB_USER')}:{config('TEST_DB_PASSWORD')}"
f"@localhost:{config('TEST_DB_PORT')}/{config('TEST_DB_NAME')}"
)
def create_app(environ):
app = Flask(__name__)
app.config.from_object(environ)
db.init_app(app)
migrate = Migrate(app, db)
api = Api(app)
CORS(app)
[api.add_resource(*route) for route in routes]
return app