I/O
plateforme.core.api.datastructures
This module provides utilities for managing data structures within the Plateforme framework's API using FastAPI and Starlette features.
URL
Source code in .venv/lib/python3.12/site-packages/starlette/datastructures.py
Address
Bases: NamedTuple
FormData
FormData(
*args: FormData
| Mapping[str, str | UploadFile]
| list[tuple[str, str | UploadFile]],
**kwargs: str | UploadFile,
)
Headers
Headers(
headers: Mapping[str, str] | None = None,
raw: list[tuple[bytes, bytes]] | None = None,
scope: MutableMapping[str, Any] | None = None,
)
An immutable, case-insensitive multidict.
Source code in .venv/lib/python3.12/site-packages/starlette/datastructures.py
QueryParams
QueryParams(
*args: ImmutableMultiDict[Any, Any]
| Mapping[Any, Any]
| list[tuple[Any, Any]]
| str
| bytes,
**kwargs: Any,
)
Bases: ImmutableMultiDict[str, str]
An immutable multidict.
Source code in .venv/lib/python3.12/site-packages/starlette/datastructures.py
State
An object that can be used to store arbitrary state.
Used for request.state
and app.state
.
Source code in .venv/lib/python3.12/site-packages/starlette/datastructures.py
UploadFile
UploadFile(
file: BinaryIO,
*,
size: int | None = None,
filename: str | None = None,
headers: Headers | None = None,
)
Bases: UploadFile
A file uploaded in a request.
Define it as a path operation function (or dependency) parameter.
If you are using a regular def
function, you can use the upload_file.file
attribute to access the raw standard Python file (blocking, not async), useful and
needed for non-async code.
Read more about it in the FastAPI docs for Request Files.
Example
from typing import Annotated
from fastapi import FastAPI, File, UploadFile
app = FastAPI()
@app.post("/files/")
async def create_file(file: Annotated[bytes, File()]):
return {"file_size": len(file)}
@app.post("/uploadfile/")
async def create_upload_file(file: UploadFile):
return {"filename": file.filename}
Source code in .venv/lib/python3.12/site-packages/starlette/datastructures.py
write
async
write(
data: Annotated[
bytes,
Doc(
"\n The bytes to write to the file.\n "
),
],
) -> None
Write some bytes to the file.
You normally wouldn't use this from a file you read in a request.
To be awaitable, compatible with async, this is run in threadpool.
Source code in .venv/lib/python3.12/site-packages/fastapi/datastructures.py
read
async
read(
size: Annotated[
int,
Doc(
"\n The number of bytes to read from the file.\n "
),
] = -1,
) -> bytes
Read some bytes from the file.
To be awaitable, compatible with async, this is run in threadpool.
Source code in .venv/lib/python3.12/site-packages/fastapi/datastructures.py
seek
async
seek(
offset: Annotated[
int,
Doc(
"\n The position in bytes to seek to in the file.\n "
),
],
) -> None
Move to a position in the file.
Any next read or write will be done from that position.
To be awaitable, compatible with async, this is run in threadpool.
Source code in .venv/lib/python3.12/site-packages/fastapi/datastructures.py
close
async
Close the file.
To be awaitable, compatible with async, this is run in threadpool.
plateforme.core.api.requests
This module provides utilities for managing requests within the Plateforme framework's API using FastAPI and Starlette features.
HTTPConnection
A base class for incoming HTTP connections, that is used to provide
any functionality that is common to both Request
and WebSocket
.
Source code in .venv/lib/python3.12/site-packages/starlette/requests.py
Request
plateforme.core.api.responses
This module provides utilities for managing responses within the Plateforme framework's API using FastAPI and Starlette features.
Response
Response(
content: Any = None,
status_code: int = 200,
headers: Mapping[str, str] | None = None,
media_type: str | None = None,
background: BackgroundTask | None = None,
)
Source code in .venv/lib/python3.12/site-packages/starlette/responses.py
FileResponse
FileResponse(
path: str | PathLike[str],
status_code: int = 200,
headers: Mapping[str, str] | None = None,
media_type: str | None = None,
background: BackgroundTask | None = None,
filename: str | None = None,
stat_result: stat_result | None = None,
method: str | None = None,
content_disposition_type: str = "attachment",
)
Bases: Response
Source code in .venv/lib/python3.12/site-packages/starlette/responses.py
HTMLResponse
HTMLResponse(
content: Any = None,
status_code: int = 200,
headers: Mapping[str, str] | None = None,
media_type: str | None = None,
background: BackgroundTask | None = None,
)
Bases: Response
Source code in .venv/lib/python3.12/site-packages/starlette/responses.py
JSONResponse
JSONResponse(
content: Any,
status_code: int = 200,
headers: Mapping[str, str] | None = None,
media_type: str | None = None,
background: BackgroundTask | None = None,
)
ORJSONResponse
ORJSONResponse(
content: Any,
status_code: int = 200,
headers: Mapping[str, str] | None = None,
media_type: str | None = None,
background: BackgroundTask | None = None,
)
Bases: JSONResponse
JSON response using the high-performance orjson library to serialize data to JSON.
Read more about it in the FastAPI docs for Custom Response - HTML, Stream, File, others.
Source code in .venv/lib/python3.12/site-packages/starlette/responses.py
PlainTextResponse
PlainTextResponse(
content: Any = None,
status_code: int = 200,
headers: Mapping[str, str] | None = None,
media_type: str | None = None,
background: BackgroundTask | None = None,
)
Bases: Response
Source code in .venv/lib/python3.12/site-packages/starlette/responses.py
RedirectResponse
RedirectResponse(
url: str | URL,
status_code: int = 307,
headers: Mapping[str, str] | None = None,
background: BackgroundTask | None = None,
)
Bases: Response
Source code in .venv/lib/python3.12/site-packages/starlette/responses.py
StreamingResponse
StreamingResponse(
content: ContentStream,
status_code: int = 200,
headers: Mapping[str, str] | None = None,
media_type: str | None = None,
background: BackgroundTask | None = None,
)
Bases: Response
Source code in .venv/lib/python3.12/site-packages/starlette/responses.py
UJSONResponse
UJSONResponse(
content: Any,
status_code: int = 200,
headers: Mapping[str, str] | None = None,
media_type: str | None = None,
background: BackgroundTask | None = None,
)
Bases: JSONResponse
JSON response using the high-performance ujson library to serialize data to JSON.
Read more about it in the FastAPI docs for Custom Response - HTML, Stream, File, others.
Source code in .venv/lib/python3.12/site-packages/starlette/responses.py
plateforme.core.api.websockets
This module provides utilities for managing websockets within the Plateforme framework's API using FastAPI and Starlette features.
WebSocket
Bases: HTTPConnection
Source code in .venv/lib/python3.12/site-packages/starlette/websockets.py
receive
async
Receive ASGI websocket messages, ensuring valid state transitions.
Source code in .venv/lib/python3.12/site-packages/starlette/websockets.py
send
async
Send ASGI websocket messages, ensuring valid state transitions.