Results of 1 - 10 of about 38 for them (0.002 sec.)
- Bigger Applications - Multiple Files 12280
- Bigger Applications - Multiple Files Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . If you are building an application or a web API, it's rarely the case that you
...s example, the variable is called router , but you can name it however you want. We are going to include this APIRouter in the main FastAPI app, but first, let's check the dependencies and another APIRouter . Dependencies We see that we are going to...need some dependencies used in several places of the application. So we put them in their own dependencies module ( app/dependencies.py ). We will now use a simple dependency to read a custom X-Token hea...Another module with APIRouter Let's say you also have the endpoints dedicated to handling "items" from your application in the module at app/routers/items.py . You have path operations for: /items/ /items/{item_id} It's all the same structure as with... - https://man.mtool.work/fastapi/0.115/tutorial/bigger-applications/
- How To - Recipes 10849
- How To - Recipes Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Here you will see different recipes or "how to" guides for several topics . Most of these ideas wo
...uld be more or less independent , and in most cases you should only need to study them if they apply directly to your project . If something seems interesting and useful to your project, go ahead and check it,...but otherwise, you might probably just skip them. Tip If you want to learn FastAPI in a structured way (recommended), go and read the Tutorial - User Guide chapter by chap... - https://man.mtool.work/fastapi/0.115/how-to/
- Response Headers 10503
- Response Headers Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Use a Response parameter You can declare a parameter of type Response in your path operation funct
...you returned. FastAPI will use that temporal response to extract the headers (also cookies and status code), and will put them in the final response that contains the value you returned, filtered by any response_model . You can also declare the Resp...onse parameter in dependencies, and set headers (and cookies) in them. Return a Response directly You can also add headers when you return a Response directly. Create a response as described i...ng the 'X-' prefix . But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations (read more in CORS (Cross-Origin Resource Sharing) ), using the parameter expose_headers docum... - https://man.mtool.work/fastapi/0.115/advanced/response-headers/
- Custom Response Classes - File, HTML, Redirect, Streaming, etc. 10503
- Custom Response Classes - File, HTML, Redirect, Streaming, etc. There are several custom response classes you can use to create an instance and return them directly from your path operations . Read more about it in the FastAPI docs for Cust
...om Response - HTML, Stream, File, others . You can import them directly from fastapi.responses : from fastapi.responses import ( FileResponse , HTMLResponse , JSONResponse , ORJSONRespo...StreamingResponse , UJSONResponse , ) FastAPI Responses There are a couple of custom FastAPI response classes, you can use them to optimize JSON performance. ::: fastapi.responses.UJSONResponse options: members: - charset - status_code - media_type -... - https://man.mtool.work/fastapi/0.115/reference/responses/
- Repository Management 9968
- Repository Management Here's a short description of how the FastAPI repository is managed and maintained. Owner I, @tiangolo , am the creator and owner of the FastAPI repository. ? I normally give the final review to each PR before merging
...Some of the tasks they can perform include: Adding labels to PRs. Editing PR titles. Adding commits on top of PRs to tweak them. Mark answers in GitHub Discussions questions, etc. Merge some specific types of PRs. You can see the current team members...n only, and I could update or remove permissions, instructions, or membership. FastAPI Experts The people that help others the most in GitHub Discussions can become FastAPI Experts . This is normally the best way to contribute to the project. Externa... - https://man.mtool.work/fastapi/0.115/management/
- Custom Docs UI Static Assets (Self-Hosting) 9418
- Custom Docs UI Static Assets (Self-Hosting) Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . The API docs use Swagger UI and ReDoc , and each of those need some Jav
...e the automatic docs The first step is to disable the automatic docs, as by default, those use the default CDN. To disable them, set their URLs to None when creating your FastAPI app: Python 3.8+ from fastapi import FastAPI from fastapi.openapi.docs...operations for the custom docs. You can reuse FastAPI's internal functions to create the HTML pages for the docs, and pass them the needed arguments: openapi_url : the URL where the HTML page for the docs can get the OpenAPI schema for your API. You...a local network. Here you'll see how to serve those files yourself, in the same FastAPI app, and configure the docs to use them. Project file structure Let's say your project file structure looks like this: . ├── app │ ├── __init__.py │ ├── main.py N... - https://man.mtool.work/fastapi/0.115/how-to/custom-docs-ui-assets/
- General - How To - Recipes 9418
- General - How To - Recipes Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Here are several pointers to other places in the docs, for general or frequent questions
...for Tutorial - Response Model - Return Type . Documentation Tags - OpenAPI To add tags to your path operations , and group them in the docs UI, read the docs for Tutorial - Path Operation Configurations - Tags . Documentation Summary and Description...- OpenAPI To add a summary and description to your path operations , and show them in the docs UI, read the docs for Tutorial - Path Operation Configurations - Summary and Description . Documentation Respo... - https://man.mtool.work/fastapi/0.115/how-to/general/
- Using Dataclasses 8883
- Using Dataclasses Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . FastAPI is built on top of Pydantic , and I have been showing you how to use Pydantic models to d
...might still need to use Pydantic models. But if you have a bunch of dataclasses laying around, this is a nice trick to use them to power a web API using FastAPI. ? Dataclasses in response_model You can also use dataclasses in the response_model param...FastAPI () @app . get ( "/items/next" , response_model = Item ) async def read_next_item (): return { "name" : "Island In The Moon" , "price" : 12.99 , "description" : "A place to be playin' and havin' fun" , "tags" : [ "breater" ], } The dataclass...List [ Author ]) # (7) def get_authors (): # (8) return [ # (9) { "name" : "Breaters" , "items" : [ { "name" : "Island In The Moon" , "description" : "A place to be playin' and havin' fun" , }, { "name" : "Holy Buddies" }, ], }, { "name" : "System o... - https://man.mtool.work/fastapi/0.115/advanced/dataclasses/
- Response - Change Status Code 8883
- Response - Change Status Code Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You probably read before that you can set a default Response Status Code . But in som
...you returned. FastAPI will use that temporal response to extract the status code (also cookies and headers), and will put them in the final response that contains the value you returned, filtered by any response_model . You can also declare the Resp...onse parameter in dependencies, and set the status code in them. But keep in mind that the last one to be set will win.... - https://man.mtool.work/fastapi/0.115/advanced/response-change-status-code/
- OpenAPI 8711
- OpenAPI There are several utilities to handle OpenAPI. You normally don't need to use them unless you have a specific advanced use case that requires it.
... - https://man.mtool.work/fastapi/0.115/reference/openapi/