* validated llm translation * validated llm translation * validated llm translation * validated llm translation * validated llm translation * validated llm translation * validated llm translation * validated llm translation * validated llm translation * validated llm translation * validated llm translation * validated llm translation * validated llm translation * validated llm translation * validated llm translation * validated llm translation * validated llm translation * fix non-Annotated in llm-prompt * rerun after a few changes in llm-prompt * fix non-Annotated * validated llm translation * fix llm translation * update outdated translations * fix translation for operation IDs * add header link * add missing link * fix line break * fix diff * fix llm translation * fix 'Atualize' to 'Atualizar' * update alternatives.md * update async.md * update fastapi-cli.md * update features.md * update help-fastapi.md * update history-design-future.md * update index.md * update advanced/events.md * update advanced/middleware.md * update advanced/response-cookies.md * update advanced/response-headers.md * update advanced/templates.md * update advanced/testing-websockets.md * update advanced/using-request-directly.md * update advanced/websockets.md * update advanced/security/oauth2-scopes.md * update deployment/cloud.md * update deployment/manually.md * update how-to/custom-request-and-route.md * update how-to/migrate-from-pydantic-v1-to-pydantic-v2.md * update tutorial/background-tasks.md * update tutorial/first-steps.md * update tutorial/handling-errors.md * update tutorial/middleware.md * update tutorial/request-files.md * update tutorial/sql-databases.md * update tutorial/static-files.md * update tutorial/testing.md * update tutorial/dependencies/dependencies-with-yield.md * update advanced/advanced-dependencies.md --------- Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
1.2 KiB
Adicionando WSGI - Flask, Django, entre outros
Como você viu em Subaplicações - Montagens{.internal-link target=_blank} e Atrás de um Proxy{.internal-link target=_blank}, você pode montar aplicações WSGI.
Para isso, você pode utilizar o WSGIMiddleware para encapsular a sua aplicação WSGI, como por exemplo Flask, Django, etc.
Usando WSGIMiddleware
Você precisa importar o WSGIMiddleware.
Em seguida, encapsule a aplicação WSGI (e.g. Flask) com o middleware.
E então monte isso sob um path.
{* ../../docs_src/wsgi/tutorial001.py hl[2:3,3] *}
Confira
Agora, todas as requisições sob o path /v1/ serão manipuladas pela aplicação Flask.
E o resto será manipulado pelo FastAPI.
Se você rodar a aplicação e ir até http://localhost:8000/v1/, você verá o retorno do Flask:
Hello, World from Flask!
E se você for até http://localhost:8000/v2, você verá o retorno do FastAPI:
{
"message": "Hello World"
}