コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 10 of about 11 for datetime (0.009 sec.)
追加データ型 12838
追加データ型 今までは、以下のような一般的なデータ型を使用してきました: int float str bool しかし、より複雑なデータ型を使用することもできます。 そして、今まで見てきたのと同じ機能を持つことになります: 素晴らしいエディタのサポート 受信したリク ... 通のIDとして使用される、標準的な「ユニバーサルにユニークな識別子」です。 リクエストとレスポンスでは str として表現されます。 datetime.datetime : Pythonの datetime.datetime です。 リクエストとレスポンスはISO 8601形式の str で表現されます: 2008-09-15T15:53:0 ... 0+05:00 datetime.date : Pythonの datetime.date です。 リクエストとレスポンスはISO 8601形式の str で表現されます: 2008-09-15 datetime.time : ... Pythonの datetime.time . リクエストとレスポンスはISO 8601形式の str で表現されます: 14:23:55.003 datetime.timedelta : Pythonの datetime.time ...
https://man.mtool.work/fastapi/0.115/tutorial/extra-data-types/
OAuth2 scopes 10864
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 ... l - User Guide for OAuth2 with Password (and hashing), Bearer with JWT tokens . Now using OAuth2 scopes: Python 3.10+ from datetime import datetime , timedelta , timezone from typing import Annotated import jwt from fastapi import Depends , FastAPI , HTT ... ss_token ( data : dict , expires_delta : timedelta | None = None ): to_encode = data . copy () if expires_delta : expire = datetime . now ( timezone . utc ) + expires_delta else : expire = datetime . now ( timezone . utc ) + timedelta ( minutes = 15 ) to ... variants Python 3.9+ Python 3.8+ Python 3.10+ - non-Annotated Python 3.9+ - non-Annotated Python 3.8+ - non-Annotated from datetime import datetime , timedelta , timezone from typing import Annotated , Union import jwt from fastapi import Depends , FastA ...
https://man.mtool.work/fastapi/0.115/advanced/security/oauth2-scopes/
パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer 10740
パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer これでセキュリティの流れが全てわかったので、 JWT トークンと安全なパスワードのハッシュ化を使用して、実際にアプリケーションを安全にしてみましょう。 このコードは、アプリケーシ ... うかを検証するユーティリティも作成します。 さらに、ユーザーを認証して返す関数も作成します。 Python 3.8+ - non-Annotated from datetime import datetime , timedelta , timezone from typing import Union import jwt from fastapi import Depends , FastAPI , HTTPExc ... data : dict , expires_delta : Union [ timedelta , None ] = None ): to_encode = data . copy () if expires_delta : expire = datetime . now ( timezone . utc ) + expires_delta else : expire = datetime . now ( timezone . utc ) + timedelta ( minutes = 15 ) to ... nt_user . username }] ? Other versions and variants Python 3.10+ Python 3.9+ Python 3.8+ Python 3.10+ - non-Annotated from datetime import datetime , timedelta , timezone from typing import Annotated import jwt from fastapi import Depends , FastAPI , HTT ...
https://man.mtool.work/fastapi/0.115/tutorial/security/oauth2-jwt/
JSON互換エンコーダ 9335
JSON互換エンコーダ データ型(Pydanticモデルのような)をJSONと互換性のあるもの( dict や list など)に変更する必要がある場合があります。 例えば、データベースに保存する必要がある場合です。 そのために、 FastAPI は jsonable_encoder() 関数を提供 ... しています。 jsonable_encoder の使用 JSON互換のデータのみを受信するデータベース fase_db があるとしましょう。 例えば、 datetime オブジェクトはJSONと互換性がないので、このデーターベースには受け取られません。 そのため、 datetime オブジェクトは ISO形式 ... le_encoder を使用することができます。 Pydanticモデルのようなオブジェクトを受け取り、JSON互換版を返します: Python 3.8+ from datetime import datetime from typing import Union from fastapi import FastAPI from fastapi.encoders import jsonable_encoder from py ... dantic import BaseModel fake_db = {} class Item ( BaseModel ): title : str timestamp : datetime description : Union [ str , None ] = None app = FastAPI () @app . put ( "/items/ {id} " ) def update_item ( id : str , ite ...
https://man.mtool.work/fastapi/0.115/tutorial/encoder/
Pythonの型の紹介 8766
Pythonの型の紹介 Python 3.6以降 では「型ヒント」オプションがサポートされています。 これらの "型ヒント" は変数の 型 を宣言することができる新しい構文です。(Python 3.6以降) 変数に型を宣言することでエディターやツールがより良いサポートを提供す ... 結果のオブジェクトですべてのエディタのサポートを受けることができます。 Pydanticの公式ドキュメントから引用: Python 3.8+ from datetime import datetime from typing import List , Union from pydantic import BaseModel class User ( BaseModel ): id : int name : s ... tr = "John Doe" signup_ts : Union [ datetime , None ] = None friends : List [ int ] = [] external_data = { "id" : "123" , "signup_ts" : "2017-06-01 12:22" , "friends" ... : [ 1 , "2" , b "3" ], } user = User ( ** external_data ) print ( user ) # > User id=123 name='John Doe' signup_ts=datetime.datetime(2017, 6, 1, 12, 22) friends=[1, 2, 3] print ( user . id ) # > 123 ? Other versions and variants Python 3.10+ Pyth ...
https://man.mtool.work/fastapi/0.115/python-types/
レスポンスを直接返す 7966
レスポンスを直接返す FastAPI の path operation では、通常は任意のデータを返すことができます: 例えば、 dict 、 list 、Pydanticモデル、データベースモデルなどです。 デフォルトでは、 FastAPI は JSON互換エンコーダ で説明されている jsonable_encod ... ンツが準備できていることを保証しなければなりません。 例えば、Pydanticモデルを JSONResponse に含めるには、すべてのデータ型 ( datetime や UUID など) をJSON互換の型に変換された dict に変換しなければなりません。 このようなケースでは、レスポンスにデータを含める ... 前に jsonable_encoder を使ってデータを変換できます。 Python 3.8+ from datetime import datetime from typing import Union from fastapi import FastAPI from fastapi.encoders import jsonable_encoder from fa ... stapi.responses import JSONResponse from pydantic import BaseModel class Item ( BaseModel ): title : str timestamp : datetime description : Union [ str , None ] = None app = FastAPI () @app . put ( "/items/ {id} " ) def update_item ( id : str , ite ...
https://man.mtool.work/fastapi/0.115/advanced/response-directly/
OpenAPI Webhooks 7948
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 ... define webhooks , the same way you would define path operations , for example with @app.webhooks.post() . Python 3.8+ from datetime import datetime from fastapi import FastAPI from pydantic import BaseModel app = FastAPI () class Subscription ( BaseModel ... ): username : str monthly_fee : float start_date : datetime @app . webhooks . post ( "new-subscription" ) def new_subscription ( body : Subscription ): """ When a new user subscribes ...
https://man.mtool.work/fastapi/0.115/advanced/openapi-webhooks/
ボディ - 更新 7379
ボディ - 更新 PUT による置換での更新 項目を更新するには HTTPの PUT 操作を使用することができます。 jsonable_encoder を用いて、入力データをJSON形式で保存できるデータに変換することができます(例:NoSQLデータベース)。例えば、 datetime を str に ... der を使用します)。 これはモデルの .dict() メソッドを再度利用することに匹敵しますが、値をJSONに変換できるデータ型、例えば datetime を str に変換します。 データをDBに保存します。 更新されたモデルを返します。 Python 3.8+ from typing import List , Union fr ...
https://man.mtool.work/fastapi/0.115/tutorial/body-updates/
機能 7326
機能 FastAPIの機能 FastAPI は以下の機能をもちます: オープンスタンダード準拠 API作成のための OpenAPI 。これは、 path operations の宣言、パラメータ、ボディリクエスト、セキュリティなどを含んでいます。 JSONスキーマ を使用したデータモデルのドキュ ... な復習が必要な場合は、短いチュートリアル( Python Types )を参照してください。 型を使用した標準的なPythonを記述します: from datetime import date from pydantic import BaseModel # Declare a variable as a str # and get editor support inside the function def ...
https://man.mtool.work/fastapi/0.115/features/
FastAPI 7290
FastAPI FastAPI framework, high performance, easy to learn, fast to code, ready for production ドキュメント : https://fastapi.tiangolo.com ソースコード : https://github.com/fastapi/fastapi FastAPI は、Pythonの標準である型ヒントに基づいてPyt ... のデータや型からネットワークデータへ変換します (JSON として): Convert Python types ( str , int , float , bool , list , etc). datetime オブジェクト UUID オブジェクト データベースモデル ...などなど 2 つの代替ユーザーインターフェースを含む自動インタラクティブ ...
https://man.mtool.work/fastapi/0.115/
PREV 1 2 NEXT