mirror of
https://github.com/correl/tornado-openapi3.git
synced 2024-11-23 19:19:55 +00:00
40 lines
1 KiB
Python
40 lines
1 KiB
Python
import tornado.ioloop
|
|
import tornado.web
|
|
from tornado_openapi3.handler import OpenAPIRequestHandler
|
|
|
|
|
|
class MyRequestHandler(OpenAPIRequestHandler):
|
|
spec_dict = {
|
|
"openapi": "3.0.0",
|
|
"info": {
|
|
"title": "Simple Example",
|
|
"version": "1.0.0",
|
|
},
|
|
"paths": {
|
|
"/": {
|
|
"get": {
|
|
"responses": {
|
|
"200": {
|
|
"description": "Index",
|
|
"content": {
|
|
"text/html": {
|
|
"schema": {"type": "string"},
|
|
}
|
|
},
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
}
|
|
|
|
|
|
class RootHandler(MyRequestHandler):
|
|
async def get(self):
|
|
self.finish("Hello, World!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = tornado.web.Application([(r"/", RootHandler)])
|
|
app.listen(8888)
|
|
tornado.ioloop.IOLoop.current().start()
|