id stringlengths 16 145 | text stringlengths 1 179k | title stringclasses 1
value |
|---|---|---|
fastapi_security_advanced_user_guide/fastapipythonwebapis_217_0.txt | **Note:** To send data, you should use ` POST ` (the most common approach), `
PUT ` , ` DELETE ` , or ` PATCH ` . Sending a body with a ` GET ` request has
undefined behavior in the specifications. | |
fastapi_security_advanced_user_guide/fastapi_security_11_8.txt | from
the form field.
If there is no such user, we return an error saying "incorrect username or
password".
For the error, we use the exception ` HTTPException ` :
Python 3.10+ Python 3.9+ Python 3.8+ Python 3.10+ non-Annotated Python
3.8+ non-Annotated
from typing import Annotated
from f... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_295_0.txt | This way, you can declare path parameters and JSON request bodies, and FastAPI
will take care of doing all the data validation, serialization, and
documentation for you. You could verify it by going to the same API
documentation at ` /docs ` or by using other tools like [ Postman
](https://www.postman.com/) with a grap... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_260_0.txt | [  ](https://files.realpython.com/media/fastapi-body-
image02.e1a560532c37.png) | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_278_0.txt | from fastapi import FastAPI
from pydantic import BaseModel | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_4_0.txt | [ Learner Stories ](/learner-stories/) [ Python Newsletter ](/newsletter/) [
Python Job Board ](https://www.pythonjobshq.com) [ Meet the Team ](/team/) [
Become a Tutorial Writer ](/write-for-us/) [ Become a Video Instructor
](/become-an-instructor/) | |
fastapi_security_advanced_user_guide/fastapi_security_7_7.txt | ://www.linkedin.com/in/tiangolo "www.linkedin.com") [
](https://dev.to/tiangolo "dev.to") [ ](https://medium.com/@tiangolo
"medium.com") [ ](https://tiangolo.com "tiangolo.com")
| |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_8_3.txt | nds newsletter ](../../newsletter/)
* [ About ](../../about/)
About
* [ Alternatives, Inspiration and Comparisons ](../../alternatives/)
* [ History, Design and Future ](../../history-design-future/)
* [ Benchmarks ](../../benchmarks/)
* [ Help ](../../help/)
Help
* [ Help FastAPI - Get He... | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_7_2.txt | s/)
* [ Testing Events: startup - shutdown ](../testing-events/)
* [ Testing Dependencies with Overrides ](../testing-dependencies/)
* [ Testing a Database ](../testing-database/)
* [ Async Tests ](../async-tests/)
* [ Settings and Environment Variables ](../settings/)
* [ OpenA... | |
fastapi_security_advanced_user_guide/configuration_77_0.txt | SPEC="{ \"openapi\": \"3.0.0\" }" | |
fastapi_security_advanced_user_guide/thebenefits_37_0.txt | Jose Diaz's photo
Jose Diaz
An Introduction to AI: Definitions, Types, and Applications
An Introduction to AI: Definitions, Types, and Applications
Definition and background of artificial intelligence Artificial intelligence, or AI, is a rapidly ev… | |
fastapi_security_advanced_user_guide/anintroductiontopyth_38_0.txt | Click the “ **Try it out** ” button in the upper right corner. The **Execute**
button appears on the screen. | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_225_0.txt | # main.py | |
fastapi_security_advanced_user_guide/anintroductiontopyth_47_0.txt | fastapi.tiangolo.com | |
fastapi_security_advanced_user_guide/fastapi_security_7_5.txt | }", response_model=Item)
async def read_main(item_id: str, x_token: Annotated[str, Header()]):
if x_token != fake_secret_token:
raise HTTPException(status_code=400, detail="Invalid X-Token header")
if item_id not in fake_db:
raise HTTPException(status_code=404, detail="Item n... | |
fastapi_security_advanced_user_guide/configuration_59_0.txt | Set the value to whatever string you'd like, taking care to escape characters
where necessary | |
fastapi_security_advanced_user_guide/configuration_63_0.txt | Set the value to ` true ` or ` false ` . | |
fastapi_security_advanced_user_guide/configuration_12_0.txt | [ Swagger Codegen | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_144_0.txt | **Step 5** is to [ return ](https://realpython.com/python-return-statement/)
the content: | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_111_0.txt | Another important term to know is **operation** , which is used in reference
to any of the **HTTP request methods** : | |
fastapi_security_advanced_user_guide/configuration_100_0.txt | * [ Partners ](https://smartbear.com/partners/)
| | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_14_0.txt | * * * | |
fastapi_security_advanced_user_guide/configuration_66_0.txt |
##### Number variables | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_361_0.txt | 5 Thoughts On Python Mastery | |
fastapi_security_advanced_user_guide/anintroductiontopyth_24_0.txt | To develop and run a fastapi application, you need to install 2 packages. | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_211_0.txt | @app.get("/users/{user_id}")
async def read_user(user_id: str):
return {"user_id": user_id} | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_17_0.txt | * What Is FastAPI?
* Install FastAPI
* First Steps
* Create a First API
* Run the First API App With Uvicorn
* Check the Response
* Check the Interactive API Documentation
* Check the Alternative Interactive API Documentation
* The First API, Step by Step
* Path Parameters: Get an Item by ID
* Path Parameters With Type... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_139_0.txt | from fastapi import FastAPI | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_84_0.txt | [  ](https://files.realpython.com/media/fastapi-first-
steps-02-redoc-simple.811f594f1c70.png) | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_318_0.txt | [ » More about Sebastián ](/team/sramirez/) | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_79_0.txt | [  ](https://files.realpython.com/media/fastapi-first-
steps-01-swagger-ui-simple.c46a4a9242dd.png) | |
fastapi_security_advanced_user_guide/fastapi_security_7_1.txt | Declare Request Example Data ](../schema-extra-example/)
* [ Extra Data Types ](../extra-data-types/)
* [ Cookie Parameters ](../cookie-params/)
* [ Header Parameters ](../header-params/)
* [ Response Model - Return Type ](../response-model/)
* [ Extra Models ](../extra-models/)
... | |
fastapi_security_advanced_user_guide/fastapi_security_11_5.txt |
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[str, Depends(oauth2_scheme)]):
user = fake_decode_token(token)
... | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_6_0.txt | Skip to content
[ Follow **@fastapi** on **Twitter** to stay updated
](https://twitter.com/fastapi)
[ Subscribe to the **FastAPI and friends** newsletter 🎉
](https://fastapi.tiangolo.com/newsletter/)
[ You can now sponsor **FastAPI** 🍰 ](https://github.com/sponsors/tiangolo)
[ sponsor  ` . MUST be a
function. Function to intercept remote definition, "Try it out", and OAuth 2.0
requests. Accept... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_27_0.txt | Table of Contents | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_24_0.txt | by Sebastián Ramírez [ basics ](/tutorials/basics/) [ api ](/tutorials/api/)
[ web-dev ](/tutorials/web-dev/) | |
fastapi_security_advanced_user_guide/anintroductiontopyth_31_0.txt | app = FastAPI() | |
fastapi_security_advanced_user_guide/configuration_81_0.txt |
* [ SwaggerHub ](https://app.swaggerhub.com/help/)
* [ Open Source Tools ](/docs/open-source-tools/swagger-editor/)
* [ Swagger Editor ](/docs/open-source-tools/swagger-editor/)
* [ Swagger Editor Next ](/docs/open-source-tools/swagger-editor-next/)
* [ Swagger UI ](/docs/open-source-tools/swagger-ui/usage/)
* [ Usage... | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_3_2.txt | Testing a Database ](../testing-database/)
* [ Async Tests ](../async-tests/)
* [ Settings and Environment Variables ](../settings/)
* [ OpenAPI Callbacks ](../openapi-callbacks/)
* [ OpenAPI Webhooks ](../openapi-webhooks/)
* [ Including WSGI - Flask, Django, others ](../wsgi/)
... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_292_0.txt | app = FastAPI() | |
fastapi_security_advanced_user_guide/anintroductiontopyth_25_0.txt | * The first package is the **fastapi** package | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_279_0.txt | class Item(BaseModel):
name: str
description: Optional[str] = None
price: float
tax: Optional[float] = None | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_338_0.txt | **Join us and get access to thousands of tutorials, hands-on video courses,
and a community of expert Pythonistas:** | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_2_0.txt | Skip to content
[ Follow **@fastapi** on **Twitter** to stay updated
](https://twitter.com/fastapi)
[ Subscribe to the **FastAPI and friends** newsletter 🎉
](https://fastapi.tiangolo.com/newsletter/)
[ You can now sponsor **FastAPI** 🍰 ](https://github.com/sponsors/tiangolo)
[ sponsor 
[ ](https://github.com/tiangolo/fastapi "github.com") [
](https://discord.gg/VQjSZaeJmf "discord.gg") [ ](https://twitter.com/fastapi
"twitter.com") [ ](https://www.linkedin.com/in/tiangolo "www.linkedin.com") [
](https://dev.to/tiangolo "dev.to") [ ](https://medi... | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_5_3.txt | e ](../../project-generation/)
* [ External Links and Articles ](../../external-links/)
* [ FastAPI and friends newsletter ](../../newsletter/)
* [ About ](../../about/)
About
* [ Alternatives, Inspiration and Comparisons ](../../alternatives/)
* [ History, Design and Future ](../../history-de... | |
fastapi_security_advanced_user_guide/thebenefits_36_0.txt | MORE ARTICLES | |
fastapi_security_advanced_user_guide/configuration_43_0.txt | ` useUnsafeMarkdown ` | ` USE_UNSAFE_MARKDOWN ` | ` Boolean=false ` . When
enabled, sanitizer will leave ` style ` , ` class ` and ` data-* ` attributes
untouched on all HTML Elements declared inside markdown strings. This
parameter is **Deprecated** and will be removed in ` 4.0.0 ` .
` onComplete ` | _Unavailable_ ... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_12_0.txt | 🔒 No spam. Unsubscribe any time. | |
fastapi_security_advanced_user_guide/fastapi_security_12_10.txt | mail="john@example.com", full_name="John Doe"
)
async def get_current_user(token: str = Depends(oauth2_scheme)):
user = fake_decode_token(token)
return user
@app.get("/users/me")
async def read_users_me(current_user: User = Depends(get_current_user)):
retu... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_271_0.txt | [  ](https://files.realpython.com/media/fastapi-body-
image05.bb8ddf770d69.png) | |
fastapi_security_advanced_user_guide/thebenefits_25_0.txt | To learn more about Swagger and OpenAPI, be sure to check out the official documentation. | |
fastapi_security_advanced_user_guide/configuration_13_0.txt | Generate server stubs and client SDKs from OpenAPI Specification definitions | |
fastapi_security_advanced_user_guide/anintroductiontopyth_65_0.txt | [ 788 Followers ](/followers?source=post_page-----
fb68d8861fad--------------------------------) | |
fastapi_security_advanced_user_guide/configuration_39_0.txt | ##### Plugins options | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_6_7.txt | JSONResponse ` . The main thing you have to do is
create a ` Response.render(content) ` method that returns the content as `
bytes ` :
from typing import Any
import orjson
from fastapi import FastAPI, Response
app = FastAPI()
class CustomORJSONResponse(Response):
... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_93_0.txt | @app.get("/")
async def root():
return {"message": "Hello World"} | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_56_0.txt | from fastapi import FastAPI | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_140_0.txt | app = FastAPI() | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_49_0.txt | With that, you have FastAPI and Uvicorn installed and are ready to learn how
to use them. FastAPI is the framework you’ll use to build your API, and
Uvicorn is the server that will use the API you build to serve requests. | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_68_0.txt | The highlighted line in the output shows the URL where your app is being
served in your local machine. Since you used ` --reload ` for development,
when you update your application code, the server will reload automatically. | |
fastapi_security_advanced_user_guide/configuration_101_0.txt | * [ Responsibility ](https://smartbear.com/company/responsibility/) | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_329_0.txt | ](/team/gahjelle/) | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_299_0.txt | By this point, you already know a lot about FastAPI and how to use it to
create robust and production-ready APIs. | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_42_0.txt | [ Remove ads ](/account/join/) | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_9_0.txt | Skip to content
[ Follow **@fastapi** on **Twitter** to stay updated
](https://twitter.com/fastapi)
[ Subscribe to the **FastAPI and friends** newsletter 🎉
](https://fastapi.tiangolo.com/newsletter/)
[ You can now sponsor **FastAPI** 🍰 ](https://github.com/sponsors/tiangolo)
[ sponsor 
standard, it also provides an alternative API documentation using ReDoc, which
you can access at ` http://127.0.0.1:8000/redoc ` : | |
fastapi_security_advanced_user_guide/configuration_94_0.txt | * [ Cucumber for Jira ](https://marketplace.atlassian.com/apps/1221264/cucumber-for-jira/?utm_medium=referral&utm_source=swagger.io&utm_campaign=footer)
* [ Cucumber Open ](https://cucumber.io/tools/cucumber-open/?utm_medium=referral&utm_source=swagger.io&utm_campaign=footer)
* [ LoadNinja ](https://loadninja.com/?utm_... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_101_0.txt | @app.get("/")
async def root():
return {"message": "Hello World"} | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_1_4.txt | self.fixed_content = fixed_content
def __call__(self, q: str = ""):
if q:
return self.fixed_content in q
return False
checker = FixedContentQueryChecker("bar")
@app.get("/query-checker/")
async def read_query_check(fixed_cont... | |
fastapi_security_advanced_user_guide/fastapi_security_6_0.txt | Skip to content
[ Follow **@fastapi** on **Twitter** to stay updated
](https://twitter.com/fastapi)
[ Subscribe to the **FastAPI and friends** newsletter 🎉
](https://fastapi.tiangolo.com/newsletter/)
[ You can now sponsor **FastAPI** 🍰 ](https://github.com/sponsors/tiangolo)
[ sponsor 
[ Subscribe to the **FastAPI and friends** newsletter 🎉
](https://fastapi.tiangolo.com/newsletter/)
[ You can now sponsor **FastAPI** 🍰 ](https://github.com/sponsors/tiangolo)
[ sponsor  | |
fastapi_security_advanced_user_guide/thebenefits_0_0.txt | blog.jjdiaz.dev | |
fastapi_security_advanced_user_guide/configuration_4_0.txt | * Pro | |
fastapi_security_advanced_user_guide/anintroductiontopyth_6_0.txt | Sign up | |
fastapi_security_advanced_user_guide/configuration_5_0.txt | * Open Source | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_174_0.txt | @app.get("/items/{item_id}")
async def read_item(item_id: int):
return {"item_id": item_id} | |
fastapi_security_advanced_user_guide/anintroductiontopyth_39_0.txt | In the next tutorial, I will be covering fastapi in more detail like the image
below. Follow me for learning Python, Machine Learning, Deep Learning and Data
Science to get extra knowledge. | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_176_0.txt | In this case, you declare ` item_id ` to be an ` int ` . | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_94_0.txt |
Copied! | |
fastapi_security_advanced_user_guide/anintroductiontopyth_17_0.txt | [
](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fbookmark%2Fp%2Ffb68d8861fad&operation=register&redirect=https%3A%2F%2Fayselaydin.medium.com%2Fan-
introduction-to-python-fastapi-swagger-ui-
fb68d8861fad&source=-----fb68d8861fad---------------------
bookmark_footer-----------) | |
fastapi_security_advanced_user_guide/anintroductiontopyth_78_0.txt | ](https://blog.medium.com/?source=post_page-----
fb68d8861fad--------------------------------) | |
fastapi_security_advanced_user_guide/fastapi_security_11_15.txt | odel
fake_users_db = {
"johndoe": {
"username": "johndoe",
"full_name": "John Doe",
"email": "johndoe@example.com",
"hashed_password": "fakehashedsecret",
"disabled": False,
},
"alice": {
"username": "alice",
... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_200_0.txt | ### Data Handling With pydantic | |
fastapi_security_advanced_user_guide/thebenefits_39_0.txt |
Jose Diaz's photo
Jose Diaz
MongoDB: The Pros and Cons of Using a NoSQL Database
MongoDB: The Pros and Cons of Using a NoSQL Database
MongoDB is a popular, open-source database management system that is designed for storing and managi… | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_36_0.txt | To get the most out of this tutorial, it would be helpful for you to know the
basics of [ what HTTP is and how it works ](https://developer.mozilla.org/en-
US/docs/Web/HTTP/Overview) , [ what JSON is ](https://realpython.com/python-
json/) , and [ Python type hints ](https://fastapi.tiangolo.com/python-types/)
. You wi... | |
fastapi_security_advanced_user_guide/thebenefits_8_0.txt | Swagger Codegen for generating API client libraries and server stubs | |
fastapi_security_advanced_user_guide/fastapi_security_8_1.txt | * [ Declare Request Example Data ](../schema-extra-example/)
* [ Extra Data Types ](../extra-data-types/)
* [ Cookie Parameters ](../cookie-params/)
* [ Header Parameters ](../header-params/)
* [ Response Model - Return Type ](../response-model/)
* [ Extra Models ](../extra-models/)
... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_103_0.txt | Here the ` app ` [ variable ](https://realpython.com/python-variables/) will
be an instance of the class ` FastAPI ` . This will be the main point of
interaction to create your API. | |
fastapi_security_advanced_user_guide/thebenefits_28_0.txt |
Subscribe to my newsletter
Read articles from blog.jjdiaz.dev directly inside your inbox. Subscribe to the newsletter, and don't miss out. | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_270_0.txt | The previous screenshots were taken with [ Visual Studio Code
](https://realpython.com/python-development-visual-studio-code/) . But you
would get the same editor support with [ PyCharm
](https://realpython.com/pycharm-guide/) and most of the other Python editors: | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_334_0.txt | Jacob | |
fastapi_security_advanced_user_guide/fastapi_security_6_1.txt | ody-nested-models/)
* [ Declare Request Example Data ](../schema-extra-example/)
* [ Extra Data Types ](../extra-data-types/)
* [ Cookie Parameters ](../cookie-params/)
* [ Header Parameters ](../header-params/)
* [ Response Model - Return Type ](../response-model/)
* [ Extra Mo... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_210_0.txt | @app.get("/users/me")
async def read_user_me():
return {"user_id": "the current user"} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.