add time
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
import time
|
|
|
|
| 3 |
import asyncio
|
| 4 |
|
| 5 |
app = FastAPI()
|
|
@@ -10,12 +11,12 @@ async def root():
|
|
| 10 |
|
| 11 |
@app.get("/info_sync")
|
| 12 |
def info_sync():
|
| 13 |
-
print("sync")
|
| 14 |
time.sleep(5)
|
| 15 |
return {"message": "sync"}
|
| 16 |
|
| 17 |
@app.get("/info_async")
|
| 18 |
async def info_async():
|
| 19 |
-
print("async")
|
| 20 |
await asyncio.sleep(5)
|
| 21 |
return {"message": "async"}
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
import time
|
| 3 |
+
from datetime import datetime
|
| 4 |
import asyncio
|
| 5 |
|
| 6 |
app = FastAPI()
|
|
|
|
| 11 |
|
| 12 |
@app.get("/info_sync")
|
| 13 |
def info_sync():
|
| 14 |
+
print(f"[{datetime.now()}] sync")
|
| 15 |
time.sleep(5)
|
| 16 |
return {"message": "sync"}
|
| 17 |
|
| 18 |
@app.get("/info_async")
|
| 19 |
async def info_async():
|
| 20 |
+
print(f"[{datetime.now()}] async")
|
| 21 |
await asyncio.sleep(5)
|
| 22 |
return {"message": "async"}
|