Search Options

Results per page
Sort
Preferred Languages
Advance

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

  1. docs_src/custom_request_and_route/tutorial001.py

    
    class GzipRequest(Request):
        async def body(self) -> bytes:
            if not hasattr(self, "_body"):
                body = await super().body()
                if "gzip" in self.headers.getlist("Content-Encoding"):
                    body = gzip.decompress(body)
                self._body = body
            return self._body
    
    
    class GzipRoute(APIRoute):
        def get_route_handler(self) -> Callable:
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 973 bytes
    - Viewed (0)
  2. docs_src/async_sql_databases/tutorial001.py

    
    @app.on_event("startup")
    async def startup():
        await database.connect()
    
    
    @app.on_event("shutdown")
    async def shutdown():
        await database.disconnect()
    
    
    @app.get("/notes/", response_model=List[Note])
    async def read_notes():
        query = notes.select()
        return await database.fetch_all(query)
    
    
    @app.post("/notes/", response_model=Note)
    async def create_note(note: NoteIn):
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 1.4K bytes
    - Viewed (0)
  3. docs_src/wsgi/tutorial001.py

    from flask import Flask, request
    from markupsafe import escape
    
    flask_app = Flask(__name__)
    
    
    @flask_app.route("/")
    def flask_main():
        name = request.args.get("name", "World")
        return f"Hello, {escape(name)} from Flask!"
    
    
    app = FastAPI()
    
    
    @app.get("/v2")
    def read_main():
        return {"message": "Hello World"}
    
    
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Tue May 09 14:32:00 GMT 2023
    - 443 bytes
    - Viewed (0)
  4. docs_src/response_model/tutorial001.py

        price: float
        tax: Union[float, None] = None
        tags: List[str] = []
    
    
    @app.post("/items/", response_model=Item)
    async def create_item(item: Item) -> Any:
        return item
    
    
    @app.get("/items/", response_model=List[Item])
    async def read_items() -> Any:
        return [
            {"name": "Portal Gun", "price": 42.0},
            {"name": "Plumbus", "price": 32.0},
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Jan 07 13:45:48 GMT 2023
    - 562 bytes
    - Viewed (0)
  5. docs_src/extending_openapi/tutorial001.py

    from fastapi import FastAPI
    from fastapi.openapi.utils import get_openapi
    
    app = FastAPI()
    
    
    @app.get("/items/")
    async def read_items():
        return [{"name": "Foo"}]
    
    
    def custom_openapi():
        if app.openapi_schema:
            return app.openapi_schema
        openapi_schema = get_openapi(
            title="Custom title",
            version="2.5.0",
            summary="This is a very custom OpenAPI schema",
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 737 bytes
    - Viewed (0)
  6. docs_src/websockets/tutorial001.py

                    input.value = ''
                    event.preventDefault()
                }
            </script>
        </body>
    </html>
    """
    
    
    @app.get("/")
    async def get():
        return HTMLResponse(html)
    
    
    @app.websocket("/ws")
    async def websocket_endpoint(websocket: WebSocket):
        await websocket.accept()
        while True:
            data = await websocket.receive_text()
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 1.4K bytes
    - Viewed (0)
  7. docs_src/advanced_middleware/tutorial001.py

    from fastapi import FastAPI
    from fastapi.middleware.httpsredirect import HTTPSRedirectMiddleware
    
    app = FastAPI()
    
    app.add_middleware(HTTPSRedirectMiddleware)
    
    
    @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
    - 231 bytes
    - Viewed (0)
  8. docs_src/request_forms_and_files/tutorial001.py

    from fastapi import FastAPI, File, Form, UploadFile
    
    app = FastAPI()
    
    
    @app.post("/files/")
    async def create_file(
        file: bytes = File(), fileb: UploadFile = File(), token: str = Form()
    ):
        return {
            "file_size": len(file),
            "token": token,
            "fileb_content_type": fileb.content_type,
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 317 bytes
    - Viewed (0)
  9. docs_src/cors/tutorial001.py

    ]
    
    app.add_middleware(
        CORSMiddleware,
        allow_origins=origins,
        allow_credentials=True,
        allow_methods=["*"],
        allow_headers=["*"],
    )
    
    
    @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
    - 459 bytes
    - Viewed (0)
  10. docs_src/dependencies/tutorial001.py

    from fastapi import Depends, FastAPI
    
    app = FastAPI()
    
    
    async def common_parameters(
        q: Union[str, None] = None, skip: int = 0, limit: int = 100
    ):
        return {"q": q, "skip": skip, "limit": limit}
    
    
    @app.get("/items/")
    async def read_items(commons: dict = Depends(common_parameters)):
        return commons
    
    
    @app.get("/users/")
    async def read_users(commons: dict = Depends(common_parameters)):
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 442 bytes
    - Viewed (0)
Back to top