Add UTC current time to response
This commit is contained in:
@@ -1,8 +1,13 @@
|
|||||||
from fastapi import FastAPI, Request
|
from fastapi import FastAPI, Request
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
async def read_root(request: Request):
|
async def read_root(request: Request):
|
||||||
client_host = request.client.host
|
client_host = request.client.host
|
||||||
return {"message": "ハローワールド!!", "client_ip": client_host}
|
return {
|
||||||
|
"message": "ハローワールド!!",
|
||||||
|
"client_ip": client_host,
|
||||||
|
"current_time_utc": datetime.now(timezone.utc).isoformat()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user