Skip to content

✅ 🇨🇻 - 🏺, ✳, 🎏

👆 💪 🗻 🇨🇻 🈸 👆 👀 ⏮️ 🎧 🈸 - 🗻, ⛅ 🗳.

👈, 👆 💪 ⚙️ WSGIMiddleware & ⚙️ ⚫️ 🎁 👆 🇨🇻 🈸, 🖼, 🏺, ✳, ♒️.

⚙️ WSGIMiddleware

👆 💪 🗄 WSGIMiddleware.

⤴️ 🎁 🇨🇻 (✅ 🏺) 📱 ⏮️ 🛠️.

& ⤴️ 🗻 👈 🔽 ➡.

from fastapi import FastAPI
from fastapi.middleware.wsgi import WSGIMiddleware
from flask import Flask, request
from markupsafe import escape

flask_app = Flask(__name__)


@flask_app.route("/")
def flask_main():
    name = request.args.get("name", "World")
    return f"Hello, {escape(name)} from Flask!"


app = FastAPI()


@app.get("/v2")
def read_main():
    return {"message": "Hello World"}


app.mount("/v1", WSGIMiddleware(flask_app))

✅ ⚫️

🔜, 🔠 📨 🔽 ➡ /v1/ 🔜 🍵 🏺 🈸.

& 🎂 🔜 🍵 FastAPI.

🚥 👆 🏃 ⚫️ ⏮️ Uvicorn & 🚶 http://localhost:8000/v1/ 👆 🔜 👀 📨 ⚪️➡️ 🏺:

Hello, World from Flask!

& 🚥 👆 🚶 http://localhost:8000/v2 👆 🔜 👀 📨 ⚪️➡️ FastAPI:

{
    "message": "Hello World"
}