Coverage for docs_src/wsgi/tutorial001.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-08 03:53 +0000

1from fastapi import FastAPI 1abcde

2from fastapi.middleware.wsgi import WSGIMiddleware 1abcde

3from flask import Flask, request 1abcde

4from markupsafe import escape 1abcde

5 

6flask_app = Flask(__name__) 1abcde

7 

8 

9@flask_app.route("/") 1abcde

10def flask_main(): 1abcde

11 name = request.args.get("name", "World") 1abcde

12 return f"Hello, {escape(name)} from Flask!" 1abcde

13 

14 

15app = FastAPI() 1abcde

16 

17 

18@app.get("/v2") 1abcde

19def read_main(): 1abcde

20 return {"message": "Hello World"} 1abcde

21 

22 

23app.mount("/v1", WSGIMiddleware(flask_app)) 1abcde