Results of 1 - 9 of about 9 for event (0.008 sec.)
- WebSocket 12960
- WebSocket FastAPI で WebSocket が使用できます。 WebSockets のインストール まず WebSockets のインストールが必要です。 $ pip install websockets ---> 100% WebSocket クライアント 本番環境 本番環境では、React、Vue.js、Angularなどの最新のフレーム
...CTYPE html> <html> <head> <title>Chat</title> </head> <body> <h1>WebSocket Chat</h1> <form action="" onsubmit="sendMessage(event)"> <input type="text" id="messageText" autocomplete="off"/> <button>Send</button> </form> <ul id='messages'> </ul> <script...> var ws = new WebSocket("ws://localhost:8000/ws"); ws.onmessage = function(event) { var messages = document.getElementById('messages') var message = document.createElement('li') var content = document.cr...eateTextNode(event.data) message.appendChild(content) messages.appendChild(message) }; function sendMessage(event) { var input = document.get... - https://man.mtool.work/fastapi/0.115/advanced/websockets/
- SQL (Relational) Databases 10677
- SQL (Relational) Databases Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . FastAPI doesn't require you to use a SQL (relational) database. But you can use any data
...engine ) as session : yield session SessionDep = Annotated [ Session , Depends ( get_session )] app = FastAPI () @app . on_event ( "startup" ) def on_startup (): create_db_and_tables () @app . post ( "/heroes/" ) def create_hero ( hero : Hero , sessio...engine ) as session : yield session SessionDep = Annotated [ Session , Depends ( get_session )] app = FastAPI () @app . on_event ( "startup" ) def on_startup (): create_db_and_tables () @app . post ( "/heroes/" ) def create_hero ( hero : Hero , sessio...engine ) as session : yield session SessionDep = Annotated [ Session , Depends ( get_session )] app = FastAPI () @app . on_event ( "startup" ) def on_startup (): create_db_and_tables () @app . post ( "/heroes/" ) def create_hero ( hero : Hero , sessio... - https://man.mtool.work/fastapi/0.115/tutorial/sql-databases/
- Lifespan Events 10209
- Lifespan Events Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can define logic (code) that should be executed before the application starts up . This means t
...ync def predict ( x : float ): result = ml_models [ "answer_to_everything" ]( x ) return { "result" : result } Alternative Events (deprecated) Warning The recommended way to handle the startup and shutdown is using the lifespan parameter of the FastAP...I app as described above. If you provide a lifespan parameter, startup and shutdown event handlers will no longer be called. It's all lifespan or all events, not both. You can probably skip this part. There's an...alternative way to define this logic to be executed during startup and during shutdown . You can define event handlers (functions) that need to be executed before the application starts up, or when the application is shutting down.... - https://man.mtool.work/fastapi/0.115/advanced/events/
- Testing Events: startup - shutdown 8592
- Testing Events: startup - shutdown Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . When you need your event handlers ( startup and shutdown ) to run in your tests,
...t: Python 3.8+ from fastapi import FastAPI from fastapi.testclient import TestClient app = FastAPI () items = {} @app . on_event ( "startup" ) async def startup_event (): items [ "foo" ] = { "name" : "Fighters" } items [ "bar" ] = { "name" : "Tenders"... - https://man.mtool.work/fastapi/0.115/advanced/testing-events/
- OpenAPI Webhooks 7998
- OpenAPI Webhooks Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . There are cases where you want to tell your API users that your app could call their app (sending
...a request) with some data, normally to notify of some type of event . This means that instead of the normal process of your users sending requests to your API, it's your API (or your app) th...you will send, the body of the request . You also define in some way at which moments your app will send those requests or events. And your users define in some way (for example in a web dashboard somewhere) the URL where your app should send those re...en a new user subscribes to your service we'll send you a POST request with this data to the URL that you register for the event `new-subscription` in the dashboard. """ @app . get ( "/users/" ) def read_users (): return [ "Rick" , "Morty" ] The webho... - https://man.mtool.work/fastapi/0.115/advanced/openapi-webhooks/
- OpenAPI Callbacks 7675
- OpenAPI Callbacks Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You could create an API with a path operation that could trigger a request to an external API cre
...API () class Invoice ( BaseModel ): id : str title : Union [ str , None ] = None customer : str total : float class InvoiceEvent ( BaseModel ): description : str paid : bool class InvoiceEventReceived ( BaseModel ): ok : bool invoices_callback_router...= APIRouter () @invoices_callback_router . post ( "{$callback_url}/invoices/{$request.body.id}" , response_model = InvoiceEventReceived ) def invoice_notification ( body : InvoiceEvent ): pass @app . post ( "/invoices/" , callbacks = invoices_callbac...* At this point is that the API will somehow send a POST request to the external API with the notification of the invoice event (e.g. "payment successful"). """ # Send the invoice, collect the money, send the notification (the callback) return { "msg... - https://man.mtool.work/fastapi/0.115/advanced/openapi-callbacks/
- APIRouter class 7621
- APIRouter class Here's the reference information for the APIRouter class, with all its parameters, attributes and methods. You can import the APIRouter class directly from fastapi : from fastapi import APIRouter ::: fastapi.APIRouter option
...s: members: - websocket - include_router - get - put - post - delete - options - head - patch - trace - on_event... - https://man.mtool.work/fastapi/0.115/reference/apirouter/
- FastAPI class 7585
- FastAPI class Here's the reference information for the FastAPI class, with all its parameters, attributes and methods. You can import the FastAPI class directly from fastapi : from fastapi import FastAPI ::: fastapi.FastAPI options: members
...endency_overrides - openapi - websocket - include_router - get - put - post - delete - options - head - patch - trace - on_event - middleware - exception_handler... - https://man.mtool.work/fastapi/0.115/reference/fastapi/
- Async Tests 7495
- Async Tests Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You have already seen how to test your FastAPI applications using the provided TestClient . Up to now,
...e using async/await with the new AsyncClient - the request is asynchronous. Warning If your application relies on lifespan events, the AsyncClient won't trigger these events. To ensure they are triggered, use LifespanManager from florimondmanca/asgi-l...ronous function calls in your tests (e.g. when using MongoDB's MotorClient ), remember to instantiate objects that need an event loop only within async functions, e.g. an '@app.on_event("startup") callback.... - https://man.mtool.work/fastapi/0.115/advanced/async-tests/
PREV
1
NEXT