Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 32 for apps (0.14 sec)

  1. docs_src/custom_response/tutorial002.py

    from fastapi import FastAPI
    from fastapi.responses import HTMLResponse
    
    app = FastAPI()
    
    
    @app.get("/items/", response_class=HTMLResponse)
    async def read_items():
        return """
        <html>
            <head>
                <title>Some HTML in here</title>
            </head>
            <body>
                <h1>Look ma! HTML!</h1>
            </body>
        </html>
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 352 bytes
    - Viewed (0)
  2. docs_src/body/tutorial002.py

    from fastapi import FastAPI
    from pydantic import BaseModel
    
    
    class Item(BaseModel):
        name: str
        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
    
    
    app = FastAPI()
    
    
    @app.post("/items/")
    async def create_item(item: Item):
        item_dict = item.dict()
        if item.tax:
            price_with_tax = item.price + item.tax
            item_dict.update({"price_with_tax": price_with_tax})
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 467 bytes
    - Viewed (0)
  3. docs_src/dataclasses/tutorial002.py

    
    @dataclass
    class Item:
        name: str
        price: float
        tags: List[str] = field(default_factory=list)
        description: Union[str, None] = None
        tax: Union[float, None] = None
    
    
    app = 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 be playin' and havin' fun",
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 552 bytes
    - Viewed (0)
  4. docs_src/generate_clients/tutorial002.py

    from typing import List
    
    from fastapi import FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        price: float
    
    
    class ResponseMessage(BaseModel):
        message: str
    
    
    class User(BaseModel):
        username: str
        email: str
    
    
    @app.post("/items/", response_model=ResponseMessage, tags=["items"])
    async def create_item(item: Item):
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Mar 04 22:02:18 GMT 2022
    - 755 bytes
    - Viewed (0)
  5. docs_src/path_params_numeric_validations/tutorial002.py

    from fastapi import FastAPI, Path
    
    app = FastAPI()
    
    
    @app.get("/items/{item_id}")
    async def read_items(q: str, item_id: int = Path(title="The ID of the item to get")):
        results = {"item_id": item_id}
        if q:
            results.update({"q": q})
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 265 bytes
    - Viewed (0)
  6. docs_src/handling_errors/tutorial002.py

    from fastapi import FastAPI, HTTPException
    
    app = FastAPI()
    
    items = {"foo": "The Foo Wrestlers"}
    
    
    @app.get("/items-header/{item_id}")
    async def read_item_header(item_id: str):
        if item_id not in items:
            raise HTTPException(
                status_code=404,
                detail="Item not found",
                headers={"X-Error": "There goes my error"},
            )
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 404 bytes
    - Viewed (0)
  7. docs_src/dependencies/tutorial002.py

    from typing import Union
    
    from fastapi import Depends, FastAPI
    
    app = FastAPI()
    
    
    fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
    
    
    class CommonQueryParams:
        def __init__(self, q: Union[str, None] = None, skip: int = 0, limit: int = 100):
            self.q = q
            self.skip = skip
            self.limit = limit
    
    
    @app.get("/items/")
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 656 bytes
    - Viewed (0)
  8. docs_src/security/tutorial002.py

    from typing import Union
    
    from fastapi import Depends, FastAPI
    from fastapi.security import OAuth2PasswordBearer
    from pydantic import BaseModel
    
    app = FastAPI()
    
    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
    
    
    def fake_decode_token(token):
        return User(
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 755 bytes
    - Viewed (0)
  9. docs_src/path_operation_advanced_configuration/tutorial002.py

    from fastapi.routing import APIRoute
    
    app = FastAPI()
    
    
    @app.get("/items/")
    async def read_items():
        return [{"item_id": "Foo"}]
    
    
    def use_route_names_as_operation_ids(app: FastAPI) -> None:
        """
        Simplify operation IDs so that generated API clients have simpler function
        names.
    
        Should be called only after all routes have been added.
        """
        for route in app.routes:
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 572 bytes
    - Viewed (0)
  10. docs_src/app_testing/tutorial002.py

    from fastapi.websockets import WebSocket
    
    app = FastAPI()
    
    
    @app.get("/")
    async def read_main():
        return {"msg": "Hello World"}
    
    
    @app.websocket("/ws")
    async def websocket(websocket: WebSocket):
        await websocket.accept()
        await websocket.send_json({"msg": "Hello WebSocket"})
        await websocket.close()
    
    
    def test_read_main():
        client = TestClient(app)
        response = client.get("/")
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Wed Feb 08 10:23:07 GMT 2023
    - 757 bytes
    - Viewed (0)
Back to top