You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use If-Modified-Since and If-Unmodified-Since headers the documentation proposes to child of FromHeader class. In this case a handler gets access to str value and this requires further manual conversion to datetime, like datetime.strptime(value, "%a, %d %b %Y %H:%M:%S %Z").
classIfUnmodifiedSince(FromHeader[Optional[str]]):
name="If-Unmodified-Since"@app.router.get("/")asyncdefupload_image(if_modified_since: IfUnmodifiedSince) ->dict:
dt=if_modified_since.valueifif_modified_sinceelseNonereturn {
"message": "This is a test endpoint for the BlackSheep application.",
"If-Unmodified-Since": dt,
}
I've tried to figure out how to use converters or BindVelue with convert to get datetime at the end. There were no workable solutions that came into my mind.
The overall idea get datetime value inside if_modified_since.value if the header is set.
Does anybody know how that can be achieved? I believe it's possible but it seems I missed something.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
To use
If-Modified-SinceandIf-Unmodified-Sinceheaders the documentation proposes to child ofFromHeaderclass. In this case a handler gets access tostrvalue and this requires further manual conversion todatetime, likedatetime.strptime(value, "%a, %d %b %Y %H:%M:%S %Z").I've tried to figure out how to use converters or
BindVeluewithconvertto getdatetimeat the end. There were no workable solutions that came into my mind.The overall idea get
datetimevalue insideif_modified_since.valueif the header is set.Does anybody know how that can be achieved? I believe it's possible but it seems I missed something.
Beta Was this translation helpful? Give feedback.
All reactions