-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
38 lines (28 loc) · 929 Bytes
/
app.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
"""Main application module"""
import swagger_ui
import tornado.ioloop
import tornado.web
from app.handlers import CarBrandHandler
from init_swagger import generate_swagger_file
SWAGGER_API_OUTPUT_FILE = "./swagger.json"
def make_app():
handlers = [
(r"/brands", CarBrandHandler),
]
# Initialize Tornado application
app = tornado.web.Application(handlers)
# Generate a fresh Swagger file
generate_swagger_file(handlers=handlers, file_location=SWAGGER_API_OUTPUT_FILE)
# Start the Swagger UI. Automatically generated swagger.json can also
# be served using a separate Swagger-service.
swagger_ui.tornado_api_doc(
app,
config_path=SWAGGER_API_OUTPUT_FILE,
url_prefix="/swagger/spec.html",
title="Car Brand API",
)
return app
if __name__ == "__main__":
app = make_app()
app.listen(8888)
tornado.ioloop.IOLoop.current().start()