Results of 1 - 10 of about 28 for check it (0.009 sec.)
check (28), it (68)
- SQL (Relational) Databases 20575
- SQL (Relational) Databases Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . FastAPI doesn't require you to use a SQL (relational) database. But you can use any data
...base that you want. Here we'll see an example using SQLModel . SQLModel is built on top of SQLAlchemy and Pydantic. It was made by the same author of FastAPI to be the perfect match for FastAPI applications that need to use SQL databases . T...n easily use any database supported by SQLAlchemy (which makes them also supported by SQLModel), like: PostgreSQL MySQL SQLite Oracle Microsoft SQL Server, etc. In this example, we'll use SQLite , because it uses a single file and Python has integr...e ) secret_name : str sqlite_file_name = "database.db" sqlite_url = f "sqlite:/// { sqlite_file_name } " connect_args = { "check_same_thread" : False } engine = create_engine ( sqlite_url , connect_args = connect_args ) def create_db_and_tables (): SQ... - https://man.mtool.work/fastapi/0.115/tutorial/sql-databases/
- Virtual Environments 19857
- Virtual Environments Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . When you work in Python projects you probably should use a virtual environment (or a similar m
.... An environment variable is a variable in the system that can be used by programs. A virtual environment is a directory with some files in it. Info This page will teach you how to use virtual environments and how they work. If you are ready to ad...ce per project , not every time you work. venv uv To create a virtual environment, you can use the venv module that comes with Python. $ python -m venv .venv What that command means python : use the program called python -m : call a module as a scr...tual environment and not any other that could be installed globally, probably with a different version than what you need. Check the Virtual Environment is Active Check that the virtual environment is active (the previous command worked). Tip This is... - https://man.mtool.work/fastapi/0.115/virtual-environments/
- Advanced Dependencies 18833
- 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
...ut there could be cases where you want to be able to set parameters on the dependency, without having to declare many different functions or classes. Let's imagine that we want to have a dependency that checks if...at 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), but an instance of that class. To do that, we declare a method __call__ : Python 3.9+ f...rom typing import Annotated from fastapi import Depends , FastAPI app = FastAPI () class FixedContentQueryChecker : def __init__ ( self , fixed_content : str ): self . fixed_content = fixed_content def __call__ ( self , q : str = "" )... - https://man.mtool.work/fastapi/0.115/advanced/advanced-dependencies/
- Repository Management Tasks 18365
- Repository Management Tasks These are the tasks that can be performed to manage the FastAPI repository by team members . Tip This section is useful only to a handful of people, team members with permissions to manage the repository. You can
...probably skip it. ? ...so, you are a team member of FastAPI ? Wow, you are so cool! ? You can help with everything on Help FastAPI - Get He...lp the same ways as external contributors. But additionally, there are some tasks that only you (as part of the team) can perform. Here are the general instructions for the ta...sn't include changes to translations. You can normally quickly detect it by going to the "Files changed" tab in the PR and checking if the updated file(s) starts with docs/en/docs . The original version of the docs is always in English, so in docs/en/... - https://man.mtool.work/fastapi/0.115/management-tasks/
- Behind a Proxy 18231
- Behind a Proxy Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In some situations, you might need to use a proxy server like Traefik or Nginx with a configuration
...SGI specification (that FastAPI is built on, through Starlette). The root_path is used to handle these specific cases. And it's also used internally when mounting sub-applications. Proxy with a stripped path prefix Having a proxy with a stripped pa...ke /api/v1 . In this case, the original path /app would actually be served at /api/v1/app . Even though all your code is written assuming there's just /app . Python 3.8+ from fastapi import FastAPI , Request app = FastAPI () @app . get ( "/app" ) d...SGI specification defines a root_path for this use case. And the --root-path command line option provides that root_path . Checking the current root_path You can get the current root_path used by your application for each request, it is part of the sc... - https://man.mtool.work/fastapi/0.115/advanced/behind-a-proxy/
- Development - Contributing 18150
- Development - Contributing Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . First, you might want to see the basic ways to help FastAPI and get help . Developing If
...you already cloned the fastapi repository and you want to deep dive in the code, here are some guidelines to set up your environment. Virtual environment Follow...nts using pip After activating the environment, install the required packages: $ pip install -r requirements.txt ---> 100% It will install all the dependencies and your local FastAPI in your local environment. Using your local FastAPI If you create...ve, that will install all the requirements. Docs live During local development, there is a script that builds the site and checks for any changes, live-reloading: $ python ./scripts/docs.py live <span style="color: green;">[INFO]</span> Serving on htt... - https://man.mtool.work/fastapi/0.115/contributing/
- Simple OAuth2 with Password and Bearer 18146
- 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
...a complete security flow. Get the username and password We are going to use FastAPI security utilities to get the username and password . OAu...e spec says that the fields have to be named like that. So user-name or email wouldn't work. But don't worry, you can show it as you wish to your final users in the frontend. And your database models can use any other names you want. But for the lo...username ] return UserInDB ( ** user_dict ) def fake_decode_token ( token ): # This doesn't provide any security at all # Check the next version user = get_user ( fake_users_db , token ) return user async def get_current_user ( token : Annotated [ st... - https://man.mtool.work/fastapi/0.115/tutorial/security/simple-oauth2/
- Bigger Applications - Multiple Files 17909
- 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
...erything in a single file. FastAPI provides a convenience tool to structure your application while keeping all the flexibility. Info If you come from Flask, this would be the equivalent of Flask's Blueprints. An example file structure Let's say you...have a file structure like this: . ├── app │ ├── __init__.py │ ├── main.py │ ├── dependencies.py │ └── routers │ │ ├── __init__.py │ │ ├── items.py │ │ └── users.py │ └── interna...r , 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 p... - https://man.mtool.work/fastapi/0.115/tutorial/bigger-applications/
- Lifespan Events 17368
- Lifespan Events Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can define logic (code) that should be executed before the application starts up . This means t
...dled possibly many requests . Because this code is executed before the application starts taking requests, and right after it finishes handling requests, it covers the whole application lifespan (the word "lifespan" will be important in a second ?)...up afterwards. For example, a database connection pool, or loading a shared machine learning model. Use Case Let's start with an example use case and then see how to solve it with this. Let's imagine that you have some machine learning models that...ion starts. And the part after the yield will be executed after the application has finished. Async Context Manager If you check, the function is decorated with an @asynccontextmanager . That converts the function into something called an " async cont... - https://man.mtool.work/fastapi/0.115/advanced/events/
- Separate OpenAPI Schemas for Input and Output or Not 16775
- Separate OpenAPI Schemas for Input and Output or Not Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . When using Pydantic v2 , the generated OpenAPI is a bit more e
...xact and correct than before. ? In fact, in some cases, it will even have two JSON Schemas in OpenAPI for the same Pydantic model, for input and output, depending on if they have de...fault values . Let's see how that works and how to change it if you need to do that. Pydantic Models for Input and Output Let's say you have a Pydantic model with default values, like...g for that field, it will still have that default value . Model for Output Response Data If you interact with the docs and check the response, even though the code didn't add anything in one of the description fields, the JSON response contains the de... - https://man.mtool.work/fastapi/0.115/how-to/separate-openapi-schemas/