-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
47 lines (41 loc) · 1.08 KB
/
server.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
"""
ENDPOINTS:
* / [GET,POST]
* /desc [GET]
* /heroes/{name} [GET]
* /all [GET]
* /all_names [GET]
* /order/ [POST]
"""
import warnings
warnings.filterwarnings('ignore')
import os
from flask import Flask
from flask_cors import CORS
from flask_swagger_ui import get_swaggerui_blueprint
from routes import routes
import configs as cfg
routes = routes.get_routes()
# SwaggerUI config
SWAGGER_BLUEPRINT = get_swaggerui_blueprint(
cfg.SERVER_SETTINGS.get('SWAGGER_URL'),
cfg.SERVER_SETTINGS.get('SWAGGER_API_URL'),
config={
'app_name':'flask_swagger_api'
},
blueprint_name='dota_hero_api'
)
app = Flask(__name__)
# Registering the routes
app.register_blueprint(routes)
# Registering the swagger blueprint
app.register_blueprint(
SWAGGER_BLUEPRINT,
url_prefix=cfg.SERVER_SETTINGS.get('SWAGGER_URL')
)
# Driver code
if __name__ == '__main__':
PORT = int(os.environ.get('PORT', cfg.SERVER_SETTINGS.get('PORT')))
CORS = CORS(app)
# Dev mode run
app.run(port=PORT, debug=True)