Загрузить файлы в «venv/Lib/site-packages/fastapi»
This commit is contained in:
25
venv/Lib/site-packages/fastapi/__init__.py
Normal file
25
venv/Lib/site-packages/fastapi/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
"""FastAPI framework, high performance, easy to learn, fast to code, ready for production"""
|
||||||
|
|
||||||
|
__version__ = "0.139.0"
|
||||||
|
|
||||||
|
from starlette import status as status
|
||||||
|
|
||||||
|
from .applications import FastAPI as FastAPI
|
||||||
|
from .background import BackgroundTasks as BackgroundTasks
|
||||||
|
from .datastructures import UploadFile as UploadFile
|
||||||
|
from .exceptions import HTTPException as HTTPException
|
||||||
|
from .exceptions import WebSocketException as WebSocketException
|
||||||
|
from .param_functions import Body as Body
|
||||||
|
from .param_functions import Cookie as Cookie
|
||||||
|
from .param_functions import Depends as Depends
|
||||||
|
from .param_functions import File as File
|
||||||
|
from .param_functions import Form as Form
|
||||||
|
from .param_functions import Header as Header
|
||||||
|
from .param_functions import Path as Path
|
||||||
|
from .param_functions import Query as Query
|
||||||
|
from .param_functions import Security as Security
|
||||||
|
from .requests import Request as Request
|
||||||
|
from .responses import Response as Response
|
||||||
|
from .routing import APIRouter as APIRouter
|
||||||
|
from .websockets import WebSocket as WebSocket
|
||||||
|
from .websockets import WebSocketDisconnect as WebSocketDisconnect
|
||||||
3
venv/Lib/site-packages/fastapi/__main__.py
Normal file
3
venv/Lib/site-packages/fastapi/__main__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from fastapi.cli import main
|
||||||
|
|
||||||
|
main()
|
||||||
4768
venv/Lib/site-packages/fastapi/applications.py
Normal file
4768
venv/Lib/site-packages/fastapi/applications.py
Normal file
File diff suppressed because it is too large
Load Diff
61
venv/Lib/site-packages/fastapi/background.py
Normal file
61
venv/Lib/site-packages/fastapi/background.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
from collections.abc import Callable
|
||||||
|
from typing import Annotated, Any
|
||||||
|
|
||||||
|
from annotated_doc import Doc
|
||||||
|
from starlette.background import BackgroundTasks as StarletteBackgroundTasks
|
||||||
|
from typing_extensions import ParamSpec
|
||||||
|
|
||||||
|
P = ParamSpec("P")
|
||||||
|
|
||||||
|
|
||||||
|
class BackgroundTasks(StarletteBackgroundTasks):
|
||||||
|
"""
|
||||||
|
A collection of background tasks that will be called after a response has been
|
||||||
|
sent to the client.
|
||||||
|
|
||||||
|
Read more about it in the
|
||||||
|
[FastAPI docs for Background Tasks](https://fastapi.tiangolo.com/tutorial/background-tasks/).
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from fastapi import BackgroundTasks, FastAPI
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
||||||
|
def write_notification(email: str, message=""):
|
||||||
|
with open("log.txt", mode="w") as email_file:
|
||||||
|
content = f"notification for {email}: {message}"
|
||||||
|
email_file.write(content)
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/send-notification/{email}")
|
||||||
|
async def send_notification(email: str, background_tasks: BackgroundTasks):
|
||||||
|
background_tasks.add_task(write_notification, email, message="some notification")
|
||||||
|
return {"message": "Notification sent in the background"}
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
|
||||||
|
def add_task(
|
||||||
|
self,
|
||||||
|
func: Annotated[
|
||||||
|
Callable[P, Any],
|
||||||
|
Doc(
|
||||||
|
"""
|
||||||
|
The function to call after the response is sent.
|
||||||
|
|
||||||
|
It can be a regular `def` function or an `async def` function.
|
||||||
|
"""
|
||||||
|
),
|
||||||
|
],
|
||||||
|
*args: P.args,
|
||||||
|
**kwargs: P.kwargs,
|
||||||
|
) -> None:
|
||||||
|
"""
|
||||||
|
Add a function to be called in the background after the response is sent.
|
||||||
|
|
||||||
|
Read more about it in the
|
||||||
|
[FastAPI docs for Background Tasks](https://fastapi.tiangolo.com/tutorial/background-tasks/).
|
||||||
|
"""
|
||||||
|
return super().add_task(func, *args, **kwargs)
|
||||||
13
venv/Lib/site-packages/fastapi/cli.py
Normal file
13
venv/Lib/site-packages/fastapi/cli.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
try:
|
||||||
|
from fastapi_cli.cli import main as cli_main
|
||||||
|
|
||||||
|
except ImportError: # pragma: no cover
|
||||||
|
cli_main = None # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
if not cli_main: # type: ignore[truthy-function]
|
||||||
|
message = 'To use the fastapi command, please install "fastapi[standard]":\n\n\tpip install "fastapi[standard]"\n'
|
||||||
|
print(message)
|
||||||
|
raise RuntimeError(message) # noqa: B904
|
||||||
|
cli_main()
|
||||||
Reference in New Issue
Block a user