sleep
Browse files
app.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
from fastapi import FastAPI
|
|
|
|
|
|
|
| 2 |
|
| 3 |
app = FastAPI()
|
| 4 |
|
|
@@ -8,8 +10,10 @@ async def root():
|
|
| 8 |
|
| 9 |
@app.get("/info_sync")
|
| 10 |
def info_sync():
|
|
|
|
| 11 |
return {"message": "sync"}
|
| 12 |
|
| 13 |
@app.get("/info_async")
|
| 14 |
async def info_async():
|
|
|
|
| 15 |
return {"message": "async"}
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
+
import time
|
| 3 |
+
import asyncio
|
| 4 |
|
| 5 |
app = FastAPI()
|
| 6 |
|
|
|
|
| 10 |
|
| 11 |
@app.get("/info_sync")
|
| 12 |
def info_sync():
|
| 13 |
+
time.sleep(1)
|
| 14 |
return {"message": "sync"}
|
| 15 |
|
| 16 |
@app.get("/info_async")
|
| 17 |
async def info_async():
|
| 18 |
+
asyncio.sleep(1)
|
| 19 |
return {"message": "async"}
|