-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
63 lines (49 loc) · 1.55 KB
/
config.py
File metadata and controls
63 lines (49 loc) · 1.55 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from decouple import config
from flask import Flask
from flask_cors import CORS
from flask_migrate import Migrate
from flask_restful import Api
from flask_swagger_ui import get_swaggerui_blueprint
from db import db
from resources.routes import routes
class ProductionConfig:
FLASK_ENV = "prod"
DEBUG = False
TESTING = False
SQLALCHEMY_DATABASE_URI = (
f"postgresql://{config('DB_USER')}:{config('DB_PASSWORD')}"
f"@{config('DB_HOST')}:{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"@{config('DB_HOST')}:{config('DB_PORT')}/{config('DB_NAME')}"
)
class TestingConfig:
FLASK_ENV = "testing"
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(environment):
app = Flask(__name__)
app.config.from_object(environment)
db.init_app(app)
migrate = Migrate(app, db)
api = Api(app)
CORS(app)
[api.add_resource(*route) for route in routes]
SWAGGER_URL = '/swagger'
API_URL = '/swagger.json'
swaggerui_blueprint = get_swaggerui_blueprint(
SWAGGER_URL,
API_URL,
config={'app_name': "Online Appointment Booking System"}
)
app.register_blueprint(swaggerui_blueprint, url_prefix=SWAGGER_URL)
return app