Results of 1 - 10 of about 59 for http (0.008 sec.)
- Behind a Proxy 13480
- Behind a Proxy Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In some situations, you might need to use a proxy server like Traefik or Nginx with a configuration
...app, the frontend needs to fetch the OpenAPI schema at /api/v1/openapi.json . graph LR browser("Browser") proxy["Proxy on http://0.0.0.0:9999/api/v1/app"] server["Server on http://127.0.0.1:8000/app"] browser --> proxy proxy --> server Tip The IP 0....on --root-path like: $ fastapi run main.py --root-path /api/v1 <span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) If you use Hypercorn, it also has the option --root-path . Technical Details The A...start Uvicorn with: $ fastapi run main.py --root-path /api/v1 <span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) The response would be something like: { "message" : "Hello World" , "root_path" :... - https://man.mtool.work/fastapi/0.115/advanced/behind-a-proxy/
- CORS (オリジン間リソース共有) 10985
- CORS (オリジン間リソース共有) CORSまたは「オリジン間リソース共有」 は、ブラウザで実行されているフロントエンドにバックエンドと通信するJavaScriptコードがあり、そのバックエンドがフロントエンドとは異なる「オリジン」にある状況を指します。 オリジ
...ン オリジンはプロトコル ( http 、 https ) とドメイン ( myapp.com 、 localhost 、 localhost.tiangolo.com ) とポート ( 80 、 443 、 8080 ) の組み合わせです...。 したがって、以下はすべて異なるオリジンです: http://localhost https://localhost http://localhost:8080 すべて localhost であっても、異なるプロトコルやポートを使用するので、異...なる「オリジン」です。 ステップ そして、ブラウザ上で実行されているフロントエンド ( http://localhost:8080 ) があり、そのJavaScriptが http://localhost で実行されているバックエンドと通信するとします。(ポートを指定... - https://man.mtool.work/fastapi/0.115/tutorial/cors/
- OAuth2 scopes 10110
- OAuth2 scopes Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can use OAuth2 scopes directly with FastAPI , they are integrated to work seamlessly. This would
...permissions, for example: users:read or users:write are common examples. instagram_basic is used by Facebook / Instagram. https://www.googleapis.com/auth/drive is used by Google. Info In OAuth2 a "scope" is just a string that declares a specific per...ime import datetime , timedelta , timezone from typing import Annotated import jwt from fastapi import Depends , FastAPI , HTTPException , Security , status from fastapi.security import ( OAuth2PasswordBearer , OAuth2PasswordRequestForm , SecuritySco..._value = f 'Bearer scope=" { security_scopes . scope_str } "' else : authenticate_value = "Bearer" credentials_exception = HTTPException ( status_code = status . HTTP_401_UNAUTHORIZED , detail = "Could not validate credentials" , headers = { "WWW-Aut... - https://man.mtool.work/fastapi/0.115/advanced/security/oauth2-scopes/
- パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer 9760
- パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer これでセキュリティの流れが全てわかったので、 JWT トークンと安全なパスワードのハッシュ化を使用して、実際にアプリケーションを安全にしてみましょう。 このコードは、アプリケーシ
...限を変更しようとした場合、署名が一致しないため、トークンの修正を検知できます。 JWT トークンを使って遊んでみたいという方は、 https://jwt.io をチェックしてください。 python-jose のインストール PythonでJWTトークンの生成と検証を行うために、 python-jose を...atetime import datetime , timedelta , timezone from typing import Union import jwt from fastapi import Depends , FastAPI , HTTPException , status from fastapi.security import OAuth2PasswordBearer , OAuth2PasswordRequestForm from jwt.exceptions import...ORITHM ) return encoded_jwt async def get_current_user ( token : str = Depends ( oauth2_scheme )): credentials_exception = HTTPException ( status_code = status . HTTP_401_UNAUTHORIZED , detail = "Could not validate credentials" , headers = { "WWW-Aut... - https://man.mtool.work/fastapi/0.115/tutorial/security/oauth2-jwt/
- エラーハンドリング 9701
- エラーハンドリング APIを使用しているクライアントにエラーを通知する必要がある状況はたくさんあります。 このクライアントは、フロントエンドを持つブラウザ、誰かのコード、IoTデバイスなどが考えられます。 クライアントに以下のようなことを伝える必要が
...きません。 クライアントがアクセスしようとしていた項目が存在しません。 など これらの場合、通常は 400 (400から499)の範囲内の HTTPステータスコード を返すことになります。 これは200のHTTPステータスコード(200から299)に似ています。これらの「200」ステータス...タスコードは、クライアントからのエラーがあったことを意味します。 "404 Not Found" のエラー(およびジョーク)を覚えていますか? HTTPException の使用 HTTPレスポンスをエラーでクライアントに返すには、 HTTPException を使用します。 HTTPException のインポート P...ython 3.8+ from fastapi import FastAPI , HTTPException app = FastAPI () items = { "foo" : "The Foo Wrestlers" } @app . get ( "/items/ {item_id} " ) async def read_item... - https://man.mtool.work/fastapi/0.115/tutorial/handling-errors/
- HTTPS について 9643
- HTTPS について HTTPSは単に「有効」か「無効」かで決まるものだと思いがちです。 しかし、それよりもはるかに複雑です。 Tip もし急いでいたり、HTTPSの仕組みについて気にしないのであれば、次のセクションに進み、さまざまなテクニックを使ってすべてをセッ
...トアップするステップ・バイ・ステップの手順をご覧ください。 利用者の視点から HTTPS の基本を学ぶ に当たっては、次のリソースをオススメします: https://howhttps.works/ . さて、 開発者の視点 から、HTTPSについて...考える際に念頭に置くべきことをいくつかみていきましょう: HTTPSの場合、 サーバ は 第三者 によって生成された**「証明書」を持つ**必要があります。 これらの証明書は「生成」されたものではなく...ずれ失効します。 そのため 更新 をし、第三者から 再度取得 する必要があります。 接続の暗号化は TCPレベル で行われます。 それは HTTPの1つ下 のレイヤーです。 つまり、 証明書と暗号化 の処理は、 HTTPの前 に行われます。 TCPは "ドメイン "について知りません 。IP... - https://man.mtool.work/fastapi/0.115/deployment/https/
- Status Codes 9176
- Status Codes You can import the status module from fastapi : from fastapi import status status is provided directly by Starlette. It contains a group of named constants (variables) with integer status codes. For example: 200: status.HTTP_20
...0_OK 403: status.HTTP_403_FORBIDDEN etc. It can be convenient to quickly access HTTP (and WebSocket) status codes in your app, using autocomplet...tatus Code . Example from fastapi import FastAPI , status app = FastAPI () @app . get ( "/items/" , status_code = status . HTTP_418_IM_A_TEAPOT ) def read_items (): return [{ "name" : "Plumbus" }, { "name" : "Portal Gun" }] ::: fastapi.status... - https://man.mtool.work/fastapi/0.115/reference/status/
- 最初のステップ 9060
- 最初のステップ 最もシンプルなFastAPIファイルは以下のようになります: Python 3.8+ from fastapi import FastAPI app = FastAPI () @app . get ( "/" ) async def root (): return { "message" : "Hello World" } これを main.py にコピーします。 ライブサ
...ーバーを実行します: $ uvicorn main:app --reload <span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) <span style="color: green;">INFO</span>: Started reloader process [28720] <span st...る)。 --reload : コードの変更時にサーバーを再起動させる。開発用。 出力には次のような行があります: INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) この行はローカルマシンでアプリが提供されているURLを示しています。 チェック ブラウザ...で http://127.0.0.1:8000 を開きます。 次のようなJSONレスポンスが表示されます: { "message" : "Hello World" } 対話的APIドキュメント... - https://man.mtool.work/fastapi/0.115/tutorial/first-steps/
- Simple OAuth2 with Password and Bearer 9001
- Simple OAuth2 with Password and Bearer Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Now let's build from the previous chapter and add the missing parts to have
...permissions, for example: users:read or users:write are common examples. instagram_basic is used by Facebook / Instagram. https://www.googleapis.com/auth/drive is used by Google. Info In OAuth2 a "scope" is just a string that declares a specific per...pends in the path operation for /token : Python 3.10+ from typing import Annotated from fastapi import Depends , FastAPI , HTTPException , status from fastapi.security import OAuth2PasswordBearer , OAuth2PasswordRequestForm from pydantic import BaseM...rrent_user ( token : Annotated [ str , Depends ( oauth2_scheme )]): user = fake_decode_token ( token ) if not user : raise HTTPException ( status_code = status . HTTP_401_UNAUTHORIZED , detail = "Invalid authentication credentials" , headers = { "WWW... - https://man.mtool.work/fastapi/0.115/tutorial/security/simple-oauth2/
- HTTP Basic Auth 8826
- 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
...header that contains a username and a password. If it doesn't receive it, it returns an HTTP 401 "Unauthorized" error. And returns a header WWW-Authenticate with a value of Basic , and an optional realm parameter. T...e 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 scheme" using HTTPBasic . Use that security wit...h a dependency in your path operation . It returns an object of type HTTPBasicCredentials : It contains the username and password sent. Python 3.9+ from typing import Annotated from fastapi import... - https://man.mtool.work/fastapi/0.115/advanced/security/http-basic-auth/