File: nested_apiblueprint_demo.py

package info (click to toggle)
flask-openapi3 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,224 kB
  • sloc: python: 4,807; makefile: 14; javascript: 5
file content (27 lines) | stat: -rw-r--r-- 591 bytes parent folder | download
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
from flask_openapi3 import APIBlueprint, OpenAPI

app = OpenAPI(__name__)

api = APIBlueprint("book", __name__, url_prefix="/api/book")
api_english = APIBlueprint("english", __name__)
api_chinese = APIBlueprint("chinese", __name__)


@api_english.post("/english")
def create_english_book():
    return {"message": "english"}


@api_chinese.post("/chinese")
def create_chinese_book():
    return {"message": "chinese"}


# register nested api
api.register_api(api_english)
api.register_api(api_chinese)
# register api
app.register_api(api)

if __name__ == "__main__":
    app.run(debug=True)