Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 39 for cdef (0.14 sec)

  1. docs_src/security/tutorial002.py

        disabled: Union[bool, None] = None
    
    
    def fake_decode_token(token):
        return User(
            username=token + "fakedecoded", email="******@****.***", 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)):
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 755 bytes
    - Viewed (0)
  2. docs_src/generate_clients/tutorial002.py

    async def create_item(item: Item):
        return {"message": "Item received"}
    
    
    @app.get("/items/", response_model=List[Item], tags=["items"])
    async def get_items():
        return [
            {"name": "Plumbus", "price": 3},
            {"name": "Portal Gun", "price": 9001},
        ]
    
    
    @app.post("/users/", response_model=ResponseMessage, tags=["users"])
    async def create_user(user: User):
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Mar 04 22:02:18 GMT 2022
    - 755 bytes
    - Viewed (0)
  3. docs_src/dependencies/tutorial002.py

    
    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/")
    async def read_items(commons: CommonQueryParams = Depends(CommonQueryParams)):
        response = {}
        if commons.q:
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 656 bytes
    - Viewed (0)
  4. 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)
  5. 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)
  6. docs_src/request_files/tutorial002.py

    app = FastAPI()
    
    
    @app.post("/files/")
    async def create_files(files: List[bytes] = File()):
        return {"file_sizes": [len(file) for file in files]}
    
    
    @app.post("/uploadfiles/")
    async def create_upload_files(files: List[UploadFile]):
        return {"filenames": [file.filename for file in files]}
    
    
    @app.get("/")
    async def main():
        content = """
    <body>
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 811 bytes
    - Viewed (0)
  7. docs_src/path_params/tutorial002.py

    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.get("/items/{item_id}")
    async def read_item(item_id: int):
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 143 bytes
    - Viewed (0)
  8. docs_src/metadata/tutorial002.py

    from fastapi import FastAPI
    
    app = FastAPI(openapi_url="/api/v1/openapi.json")
    
    
    @app.get("/items/")
    async def read_items():
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Apr 02 04:55:20 GMT 2020
    - 154 bytes
    - Viewed (0)
  9. docs_src/advanced_middleware/tutorial002.py

    from fastapi.middleware.trustedhost import TrustedHostMiddleware
    
    app = FastAPI()
    
    app.add_middleware(
        TrustedHostMiddleware, allowed_hosts=["example.com", "*.example.com"]
    )
    
    
    @app.get("/")
    async def main():
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 279 bytes
    - Viewed (0)
  10. docs_src/query_params/tutorial002.py

    from typing import Union
    
    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.get("/items/{item_id}")
    async def read_item(item_id: str, q: Union[str, None] = None):
        if q:
            return {"item_id": item_id, "q": q}
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 251 bytes
    - Viewed (0)
Back to top