コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 10 of about 11 for instance (0.003 sec.)
Advanced Dependencies 14118
Advanced Dependencies Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Parameterized dependencies All the dependencies we have seen are a fixed function or class. B ... the query parameter q contains some fixed content. But we want to be able to parameterize that fixed content. A "callable" instance In Python there's a way to make an instance of a class a "callable". Not the class itself (which is already a callable), b ... ut an instance of that class. To do that, we declare a method __call__ : Python 3.9+ from typing import Annotated from fastapi import Dep ... , and this is what will be called to pass a value to the parameter in your path operation function later. Parameterize the instance And now, we can use __init__ to declare the parameters of the instance that we can use to "parameterize" the dependency: P ...
https://man.mtool.work/fastapi/0.115/advanced/advanced-dependencies/
Response class 9886
Response class You can declare a parameter in a path operation function or dependency to be of type Response and then you can set data for the response like headers or cookies. You can also use it directly to create an instance of it and re ...
https://man.mtool.work/fastapi/0.115/reference/response/
Custom Request and APIRoute class 8926
Custom Request and APIRoute class Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In some cases, you may want to override the logic used by the Request and APIRout ... both part of the ASGI specification. And those two things, scope and receive , are what is needed to create a new Request instance. To learn more about the Request check Starlette's docs about Requests . The only thing the function returned by GzipReque ... /" ) async def sum_numbers ( numbers : List [ int ] = Body ()): return sum ( numbers ) If an exception occurs, the Request instance will still be in scope, so we can read and make use of the request body when handling the error: Python 3.8+ from typing i ...
https://man.mtool.work/fastapi/0.115/how-to/custom-request-and-route/
Custom Response Classes - File, HTML, Redirect, Streaming, etc. 8801
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 ...
https://man.mtool.work/fastapi/0.115/reference/responses/
Settings and Environment Variables 8393
Settings and Environment Variables Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In many cases your application could need some external settings or configuratio ... ip If you want something quick to copy and paste, don't use this example, use the last one below. Then, when you create an instance of that Settings class (in this case, in the settings object), Pydantic will read the environment variables in a case-inse ... gs ): app_name : str = "Awesome API" admin_email : str items_per_user : int = 50 Notice that now we don't create a default instance settings = Settings() . The main app file Now we create a dependency that returns a new config.Settings() . Python 3.9+ fr ...
https://man.mtool.work/fastapi/0.115/advanced/settings/
FastAPI CLI 8393
FastAPI CLI Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . FastAPI CLI is a command line program that you can use to serve your FastAPI app, manage your FastAPI p ... i is FastAPI CLI . FastAPI CLI takes the path to your Python program (e.g. main.py ) and automatically detects the FastAPI instance (commonly named app ), determines the correct import process, and then serves it. For production you would use fastapi run ...
https://man.mtool.work/fastapi/0.115/fastapi-cli/
Extending OpenAPI 8250
Extending OpenAPI Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . There are some cases where you might need to modify the generated OpenAPI schema. In this section ... you will see how. The normal process The normal (default) process, is as follows. A FastAPI application (instance) has an .openapi() method that is expected to return the OpenAPI schema. As part of the application object creation, a pat ...
https://man.mtool.work/fastapi/0.115/how-to/extending-openapi/
Custom Docs UI Static Assets (Self-Hosting) 7966
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 ... ndalone.js ├── swagger-ui-bundle.js └── swagger-ui.css Serve the static files Import StaticFiles . "Mount" a StaticFiles() instance in a specific path. Python 3.8+ from fastapi import FastAPI from fastapi.openapi.docs import ( get_redoc_html , get_swagge ...
https://man.mtool.work/fastapi/0.115/how-to/custom-docs-ui-assets/
Bigger Applications - Multiple Files 7841
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 ... kage"). You can create the path operations for that module using APIRouter . Import APIRouter You import it and create an "instance" the same way you would with the class FastAPI : app/routers/users.py from fastapi import APIRouter router = APIRouter () ...
https://man.mtool.work/fastapi/0.115/tutorial/bigger-applications/
Simple OAuth2 with Password and Bearer 7557
Simple OAuth2 with Password and Bearer Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Now let's build from the previous chapter and add the missing parts to have ... ctly. But as it's a common use case, it is provided by FastAPI directly, just to make it easier. Use the form data Tip The instance of the dependency class OAuth2PasswordRequestForm won't have an attribute scope with the long string separated by spaces, ...
https://man.mtool.work/fastapi/0.115/tutorial/security/simple-oauth2/
PREV 1 2 NEXT