-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (31 loc) · 1.11 KB
/
main.py
File metadata and controls
39 lines (31 loc) · 1.11 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
# Initialize Cloud Debugger
try:
import googleclouddebugger
googleclouddebugger.enable()
except ImportError:
pass
# Logging & config
from backend.global_logger import logger
from backend.config import Config
# External packages
from flask import Flask
from flask_cors import CORS
from flask_restful import Api
# App components
from backend.cellar_routes import CellarCollectionApi, BeverageApi
from backend.picklist_routes import PicklistApi
app = Flask("cellarsync")
logger.info(f"Flask app {app.name} created!")
app.config.from_object(Config)
logger.info("Applied config parameters to the app.")
# Enable CORS for the app to ensure our UI can call the backend API
import logging
logging.getLogger('flask_cors').level = logging.DEBUG
CORS(app, resources={r"/api/*": {"origins": Config.WHITELISTED_ORIGINS}})
logger.info("CORS initialized.")
api = Api(app)
logger.info("Flask-RESTful API initialized.")
# Define the functional endpoints
api.add_resource(CellarCollectionApi, '/api/v1/cellar')
api.add_resource(BeverageApi, '/api/v1/cellar/<beverage_id>/<location>')
api.add_resource(PicklistApi, '/api/v1/picklist-data')