id stringlengths 16 145 | text stringlengths 1 179k | title stringclasses 1
value |
|---|---|---|
fastapi_security_advanced_user_guide/fastapipythonwebapis_163_0.txt | So, if you run this example and go to ` http://127.0.0.1:8000/items/foo ` ,
you will see this response: | |
fastapi_security_advanced_user_guide/anintroductiontopyth_28_0.txt | pip install uvicorn | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_208_0.txt | from fastapi import FastAPI | |
fastapi_security_advanced_user_guide/anintroductiontopyth_57_0.txt | [
](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fvote%2Fp%2Ffb68d8861fad&operation=register&redirect=https%3A%2F%2Fayselaydin.medium.com%2Fan-
introduction-to-python-fastapi-swagger-ui-
fb68d8861fad&user=Aysel+Aydin&userId=8f989c1f1548&source=-----fb68d8861fad
---------------------clap_footer---... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_313_0.txt |  | |
fastapi_security_advanced_user_guide/thebenefits_30_0.txt |
Sponsor
Learn more about Hashnode Sponsors
swagger
OpenApi
FastAPI
API development
Python
Written by | |
fastapi_security_advanced_user_guide/fastapi_security_11_6.txt | f not user_dict:
raise HTTPException(status_code=400, detail="Incorrect username or password")
user = UserInDB(**user_dict)
hashed_password = fake_hash_password(form_data.password)
if not hashed_password == user.hashed_password:
raise HTTPException(status_code=400, detail... | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_6_2.txt | * [ Advanced Security ](../security/)
Advanced Security
* [ OAuth2 scopes ](../security/oauth2-scopes/)
* [ HTTP Basic Auth ](../security/http-basic-auth/)
* [ Using the Request Directly ](../using-request-directly/)
* [ Using Dataclasses ](../dataclasses/)
* [ Advanced Mid... | |
fastapi_security_advanced_user_guide/thebenefits_29_0.txt | Enter your email address
SUBSCRIBE
Did you find this article valuable?
Support Jose Diaz by becoming a sponsor. Any amount is appreciated! | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_364_0.txt | [ Remove ads ](/account/join/) | |
fastapi_security_advanced_user_guide/anintroductiontopyth_66_0.txt | Senior Expert AI & ML Engineer @Turkcell | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_195_0.txt | [  ](https://files.realpython.com/media/fastapi-path-
params-image01.f8af7578f694.png) | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_356_0.txt | [ 
](/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Ffastapi-
python-web-apis%2F) | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_148_0.txt | app = FastAPI() | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_87_0.txt | Now let’s analyze that code step by step and understand what each part does. | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_0_1.txt | s/)
* [ Body - Fields ](../../tutorial/body-fields/)
* [ Body - Nested Models ](../../tutorial/body-nested-models/)
* [ Declare Request Example Data ](../../tutorial/schema-extra-example/)
* [ Extra Data Types ](../../tutorial/extra-data-types/)
* [ Cookie Parameters ](../../tutorial/... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_233_0.txt | For example, the model above declares a JSON object (or Python ` dict ` ) like
this: | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_9_2.txt | startup - shutdown ](../testing-events/)
* [ Testing Dependencies with Overrides ](../testing-dependencies/)
* [ Testing a Database ](../testing-database/)
* [ Async Tests ](../async-tests/)
* [ Settings and Environment Variables ](../settings/)
* [ OpenAPI Callbacks ](../openapi-cal... | |
fastapi_security_advanced_user_guide/fastapi_security_8_2.txt | dvanced/async-tests/)
* [ Settings and Environment Variables ](../../advanced/settings/)
* [ OpenAPI Callbacks ](../../advanced/openapi-callbacks/)
* [ OpenAPI Webhooks ](../../advanced/openapi-webhooks/)
* [ Including WSGI - Flask, Django, others ](../../advanced/wsgi/)
* [ Generate C... | |
fastapi_security_advanced_user_guide/anintroductiontopyth_36_0.txt | Now let's check the API documentation of this application. Type the URL [
**http://127.0.0.1:8000/docs** ](http://127.0.0.1:8000/docs) **** This will
open up the [ Swagger UI ](https://swagger.io/tools/swagger-ui/) | |
fastapi_security_advanced_user_guide/configuration_67_0.txt | Set the value to _` n ` _ , where _n_ is the number you'd like to provide. | |
fastapi_security_advanced_user_guide/configuration_17_0.txt | Visualize OpenAPI Specification definitions in an interactive UI. | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_332_0.txt | ](/team/jjablonski/) | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_0_4.txt | shampoo>
"""
return Response(content=data, media_type="application/xml")
## Notes ¶
When you return a ` Response ` directly its data is not validated, converted
(serialized), nor documented automatically.
But you can still document it as described in [ Additional Responses in
OpenAPI ](../addi... | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_6_3.txt | rs/)
* [ Static Files - ` StaticFiles ` ](../../reference/staticfiles/)
* [ Templating - ` Jinja2Templates ` ](../../reference/templating/)
* [ Test Client - ` TestClient ` ](../../reference/testclient/)
* [ FastAPI People ](../../fastapi-people/)
* [ Resources ](../../resources/)
Resources
* [ ... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_209_0.txt | app = FastAPI() | |
fastapi_security_advanced_user_guide/anintroductiontopyth_30_0.txt | from fastapi import FastAPI | |
fastapi_security_advanced_user_guide/fastapi_security_0_0.txt | [ 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  ](htt... | |
fastapi_security_advanced_user_guide/configuration_38_0.txt | Parameter name | Docker variable | Description
---|---|---
` layout ` | _Unavailable_ | ` String="BaseLayout" ` . The name of a
component available via the plugin system to use as the top-level layout for
Swagger UI.
` pluginsOptions ` | _Unavailable_ | ` Object ` . A Javascript object to
configure plugin integ... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_143_0.txt | If you don’t know the difference between normal functions and ` async `
functions and when to use them, check out [ Concurrency and async/await
](https://fastapi.tiangolo.com/async/) in the FastAPI documentation. | |
fastapi_security_advanced_user_guide/fastapi_security_10_2.txt | se/)
* [ Async Tests ](../../advanced/async-tests/)
* [ Settings and Environment Variables ](../../advanced/settings/)
* [ OpenAPI Callbacks ](../../advanced/openapi-callbacks/)
* [ OpenAPI Webhooks ](../../advanced/openapi-webhooks/)
* [ Including WSGI - Flask, Django, others ](../..... | |
fastapi_security_advanced_user_guide/configuration_3_0.txt | * Tools | |
fastapi_security_advanced_user_guide/anintroductiontopyth_10_0.txt | [ 
](/?source=post_page-----fb68d8861fad--------------------------------) | |
fastapi_security_advanced_user_guide/fastapi_security_11_9.txt | return "fakehashed" + password
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
class User(BaseModel):
username: str
email: Union[str, None] = None
full_name: Union[str, None] = None
disabled: Union[bool, None] = None
class UserInDB(User)... | |
fastapi_security_advanced_user_guide/anintroductiontopyth_77_0.txt | Blog | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_239_0.txt | {
"name": "Foo",
"price": 45.2
} | |
fastapi_security_advanced_user_guide/thebenefits_16_0.txt | @app.get("/docs")
def read_docs():
return get_swagger_ui_html(openapi_url="/openapi.json")
In this example, we define a FastAPI app and add a route that returns a "Hello, World!" message when a GET request is made to the root path of the API. We also define a route that returns the HTML for Swagger UI when a GET reques... | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_0_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  | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_64_0.txt | Shell | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_100_0.txt | app = FastAPI() | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_41_0.txt | The framework is designed to optimize your developer experience so that you
can write simple code to build production-ready APIs with best practices by
default. | |
fastapi_security_advanced_user_guide/configuration_35_0.txt | Parameter name | Docker variable | Description
---|---|---
` configUrl ` | ` CONFIG_URL ` | ` String ` . URL to fetch external
configuration document from.
` dom_id ` | ` DOM_ID ` | ` String ` , **REQUIRED** if ` domNode ` is not
provided. The ID of a DOM element inside which ` SwaggerUI ` will put its user
int... | |
fastapi_security_advanced_user_guide/configuration_74_0.txt |
##### Object variables | |
fastapi_security_advanced_user_guide/configuration_82_0.txt | [ 
](https://smartbear.com/resources/webinars/building-api-standards/) | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_118_0.txt | app = FastAPI() | |
fastapi_security_advanced_user_guide/configuration_99_0.txt | * [ Solutions ](https://smartbear.com/solutions/)
| | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_342_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_security_4_3.txt | [ Resources ](../../../resources/)
Resources
* [ Full Stack FastAPI Template ](../../../project-generation/)
* [ External Links and Articles ](../../../external-links/)
* [ FastAPI and friends newsletter ](../../../newsletter/)
* [ About ](../../../about/)
About
* [ Alternatives, Inspiration ... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_185_0.txt | If you point your browser to ` http://127.0.0.1:8000/items/foo ` , then you’ll
see a nice HTTP error: | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_223_0.txt | Next, you declare your data model as a class that inherits from ` BaseModel `
, using standard Python types for all the attributes: | |
fastapi_security_advanced_user_guide/configuration_83_0.txt |  | |
fastapi_security_advanced_user_guide/configuration_32_0.txt | Type notations are formatted like so: | |
fastapi_security_advanced_user_guide/fastapi_security_1_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-mod... | |
fastapi_security_advanced_user_guide/fastapi_security_11_19.txt | ",
"full_name": "John Doe",
"email": "johndoe@example.com",
"hashed_password": "fakehashedsecret",
"disabled": False,
},
"alice": {
"username": "alice",
"full_name": "Alice Wonderson",
"email": "alice@example.com",
... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_224_0.txt | Python | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_66_0.txt | INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [28720]
INFO: Started server process [28722]
INFO: Waiting for application startup.
INFO: Application startup complete. | |
fastapi_security_advanced_user_guide/anintroductiontopyth_60_0.txt | [ 
](/?source=post_page-----fb68d8861fad--------------------------------) | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_152_0.txt | There are many other objects and models that will be automatically converted
to JSON, including [ object-relational mappers
](https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping) (ORMs) and
others. Try using your favorite ones—it’s highly probable that they are
already supported. | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_303_0.txt | FastAPI is based on modern Python features, and you can take full advantage of
FastAPI by learning more about those features, too. Check out [ Getting
Started With Async Features in Python ](https://realpython.com/python-async-
features/) and [ Async IO in Python: A Complete Walkthrough
](https://realpython.com/async-i... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_46_0.txt | Shell | |
fastapi_security_advanced_user_guide/fastapi_security_4_2.txt | ./../../advanced/events/)
* [ Testing WebSockets ](../../../advanced/testing-websockets/)
* [ Testing Events: startup - shutdown ](../../../advanced/testing-events/)
* [ Testing Dependencies with Overrides ](../../../advanced/testing-dependencies/)
* [ Testing a Database ](../../../advanced/... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_38_0.txt | ## What Is FastAPI? | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_114_0.txt | **Step 3** is to define a **path operation decorator** : | |
fastapi_security_advanced_user_guide/fastapi_advanced_user_guide_5_2.txt |
* [ Sub Applications - Mounts ](../sub-applications/)
* [ Behind a Proxy ](../behind-a-proxy/)
* [ Templates ](../templates/)
* [ WebSockets ](../websockets/)
* [ Lifespan Events ](../events/)
* [ Testing WebSockets ](../testing-websockets/)
* [ Testing Events: startup -... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_346_0.txt | [ ](/feedback/survey/article/fastapi-python-web-apis/liked/?from=article-
comments "Liked it") [ ](/feedback/survey/article/fastapi-python-web-
apis/disliked/?from=article-comments "Disliked it") | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_259_0.txt | These JSON Schemas will also be used in the API documentation inside each path
operation that needs them: | |
fastapi_security_advanced_user_guide/configuration_71_0.txt | Set the value to the literal array value you'd like, taking care to escape
characters where necessary. | |
fastapi_security_advanced_user_guide/configuration_57_0.txt | Below are the general guidelines for using the environment variable interface. | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_236_0.txt |
Copied! | |
fastapi_security_advanced_user_guide/fastapi_security_4_6.txt | RIZED
` ) directly.
You don't even have to check if the token exists to return an error. You can
be sure that if your function is executed, it will have a ` str ` in that
token.
You can try it already in the interactive docs:

We are not verifying the validity of the token yet... | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_335_0.txt | ](/team/jschmitt/) | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_247_0.txt | class Item(BaseModel):
name: str
description: Optional[str] = None
price: float
tax: Optional[float] = None | |
fastapi_security_advanced_user_guide/thebenefits_1_0.txt |
Follow | |
fastapi_security_advanced_user_guide/configuration_8_0.txt | ](/tools/swaggerhub/) | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_39_0.txt | FastAPI is a modern, high-performance web framework for building APIs with
Python based on standard type hints. It has the following key features: | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_316_0.txt | [   | |
fastapi_security_advanced_user_guide/anintroductiontopyth_44_0.txt | ](https://github.com/AyselAydin/fastAPI?source=post_page-----
fb68d8861fad--------------------------------) | |
fastapi_security_advanced_user_guide/configuration_44_0.txt | Object={
generators: {
curl_bash: {
title: "cURL (bash)",
syntax: "bash"
},
curl_powershell: {
title: "cURL (PowerShell)",
syntax: "powershell"
},
curl_cmd: {
title: "cURL (CMD)",
syntax: "bash"
},
},
defaultExpanded: true,
languages: null,
// e.g. only show curl bash = ["curl_bash"]
} | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_238_0.txt | JSON | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_321_0.txt | [ 
](/team/asantos/) | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_322_0.txt | Aldren | |
fastapi_security_advanced_user_guide/anintroductiontopyth_71_0.txt | Status | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_54_0.txt | Python | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_2_0.txt | [ Python Tutorials →
In-depth articles and video courses
](/search?kind=article&kind=course&order=newest) [ Learning Paths →
Guided study plans for accelerated learning ](/learning-paths/) [ Quizzes →
Check your learning progress ](/quizzes/) [ Browse Topics →
Focus on a specific area or skill level ](/tutorials/all... | |
fastapi_security_advanced_user_guide/anintroductiontopyth_34_0.txt | python -m uvicorn main:app --reload | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_110_0.txt | A path is also commonly called an **endpoint** or a **route** , but the term
**path** will be used in this tutorial. When you’re building an API, the path
is the main way you can separate resources. | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_352_0.txt | Keep Learning | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_181_0.txt | {"item_id":3} | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_154_0.txt | ## Path Parameters: Get an Item by ID | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_128_0.txt | **Step 4** is to define the **path operation function** , or the function that
goes below the path operation decorator: | |
fastapi_security_advanced_user_guide/configuration_52_0.txt | ### Instance methods | |
fastapi_security_advanced_user_guide/anintroductiontopyth_63_0.txt | ## Written by Aysel Aydin | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_102_0.txt |
Copied! | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_0_0.txt | [  ](/) | |
fastapi_security_advanced_user_guide/fastapipythonwebapis_52_0.txt | ### Create a First API |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.