コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 10 of about 15 for send (0.002 sec.)
WebSocket 12574
WebSocket FastAPI で WebSocket が使用できます。 WebSockets のインストール まず WebSockets のインストールが必要です。 $ pip install websockets ---> 100% WebSocket クライアント 本番環境 本番環境では、React、Vue.js、Angularなどの最新のフレーム ... l = """ <!DOCTYPE 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'> ... ) var content = document.createTextNode(event.data) message.appendChild(content) messages.appendChild(message) }; function sendMessage(event) { var input = document.getElementById("messageText") ws.send(input.value) input.value = '' event.preventDefa ... bsocket : WebSocket ): await websocket . accept () while True : data = await websocket . receive_text () await websocket . send_text ( f "Message text was: { data } " ) websocket を作成する FastAPI アプリケーションで、 websocket を作成します。 Python ...
https://man.mtool.work/fastapi/0.115/advanced/websockets/
OpenAPI Callbacks 12034
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 ... ens when your API app calls the external API is named a "callback". Because the software that the external developer wrote sends a request to your API and then your API calls back , sending a request to an external API (that was probably created by t ... ur API (an external developer) will create an invoice in your API with a POST request. Then your API will (let's imagine): Send the invoice to some customer of the external developer. Collect the money. Send a notification back to the API user (the e ... xternal developer). This will be done by sending a POST request (from your API ) to some external API provided by that external developer (this is the "callback"). The ...
https://man.mtool.work/fastapi/0.115/advanced/openapi-callbacks/
バックグラウンドタスク 10205
バックグラウンドタスク レスポンスを返した 後に 実行されるバックグラウンドタスクを定義できます。 これは、リクエスト後に処理を開始する必要があるが、クライアントがレスポンスを受け取る前に処理を終える必要のない操作に役立ちます。 これには、たとえ ... " ) 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_tas ... " ) 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_tas ... " ) 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_tas ...
https://man.mtool.work/fastapi/0.115/tutorial/background-tasks/
OpenAPI Webhooks 10170
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 ... st) 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) that could send requests to their system (to their API, their app). T ... y called a webhook . Webhooks steps The process normally is that you define in your code what is the message that 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 y ... our users define in some way (for example in a web dashboard somewhere) the URL where your app should send those requests. All the logic about how to register the URLs for webhooks and the code to actually send those requests is ...
https://man.mtool.work/fastapi/0.115/advanced/openapi-webhooks/
WebSockets 9927
WebSockets When defining WebSockets, you normally declare a parameter of type WebSocket and with it you can read data from the client and send data to it. It is provided directly by Starlette, but you can import it from fastapi : from fasta ... - headers - query_params - path_params - cookies - client - state - url_for - client_state - application_state - receive - send - accept - receive_text - receive_bytes - receive_json - iter_text - iter_bytes - iter_json - send_text - send_bytes - sen ...
https://man.mtool.work/fastapi/0.115/reference/websockets/
Form Models 7924
Form Models Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can use Pydantic models to declare form fields in FastAPI. Info To use forms, first install python- ... tra" : "forbid" } @app . post ( "/login/" ) async def login ( data : FormData = Form ()): return data If a client tries to send some extra data, they will receive an error response. For example, if the client tries to send the form fields: username : ...
https://man.mtool.work/fastapi/0.115/tutorial/request-form-models/
Testing WebSockets 7767
Testing WebSockets Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can use the same TestClient to test WebSockets. For this, you use the TestClient in a with s ... } @app . websocket ( "/ws" ) async def websocket ( websocket : WebSocket ): await websocket . accept () await websocket . send_json ({ "msg" : "Hello WebSocket" }) await websocket . close () def test_read_main (): client = TestClient ( app ) respons ...
https://man.mtool.work/fastapi/0.115/advanced/testing-websockets/
Header Parameter Models 7732
Header Parameter Models Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . If you have a group of related header parameters , you can create a Pydantic model to decla ... @app . get ( "/items/" ) async def read_items ( headers : CommonHeaders = Header ()): return headers If a client tries to send some extra headers , they will receive an error response. For example, if the client tries to send a tool header with a va ...
https://man.mtool.work/fastapi/0.115/tutorial/header-param-models/
HTTP Basic Auth 7610
HTTP Basic Auth Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . For the simplest cases, you can use HTTP Basic Auth. In HTTP Basic Auth, the application expects a ... ser to show the integrated prompt for a username and password. Then, when you type that username and password, the browser sends them in the header automatically. Simple HTTP Basic Auth Import HTTPBasic and HTTPBasicCredentials . Create a " security ... Attacks But what's a "timing attack"? Let's imagine some attackers are trying to guess the username and password. And they send a request with a username johndoe and a password love123 . Then the Python code in your application would be equivalent to ... sword". The time to answer helps the attackers At that point, by noticing that the server took some microseconds longer to send the "Incorrect username or password" response, the attackers will know that they got something right, some of the initial ...
https://man.mtool.work/fastapi/0.115/advanced/security/http-basic-auth/
Generate Clients 7558
Generate Clients Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . As FastAPI is based on the OpenAPI specification, you get automatic compatibility with many tools, ... ld look like this, notice that you get autocompletion for the methods: You will also get autocompletion for the payload to send: Tip Notice the autocompletion for name and price , that was defined in the FastAPI application, in the Item model. You wi ... ll have inline errors for the data that you send: The response object will also have autocompletion: FastAPI App with Tags In many cases your FastAPI app will be bigger, a ...
https://man.mtool.work/fastapi/0.115/advanced/generate-clients/
PREV 1 2 NEXT