-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.py
More file actions
25 lines (17 loc) · 800 Bytes
/
server.py
File metadata and controls
25 lines (17 loc) · 800 Bytes
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
from sanic import Sanic
from _321CQU.tools.gRPCManager import gRPCManager
from utils.Exceptions import _321CQUErrorHandler
from utils.log_config import LogConfig
from utils.Metrics import register_metrics
from utils.SqlManager import SqlManager, SqliteManager
from api import *
app = Sanic('API_Gateway', log_config=LogConfig)
app.config.CORS_ORIGINS = ["http://321cqu.com", "https://321cqu.com", "http://api.321cqu.com", "https://api.321cqu.com"]
app.config.CORS_SUPPORTS_CREDENTIALS = True
app.error_handler = _321CQUErrorHandler()
app.ext.add_dependency(SqlManager, SqliteManager)
app.ext.add_dependency(gRPCManager, lambda: gRPCManager(caller="api_gateway"))
app.blueprint(api_urls)
register_metrics(app)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000, access_log=True)