Skip to content
  • This project
    • Loading...
  • Sign in

周伟奇 / part_of_F3_OCR

Go to a project
Toggle navigation
Toggle navigation pinning
  • Projects
  • Groups
  • Snippets
  • Help
  • Project
  • Activity
  • Repository
  • Pipelines
  • Graphs
  • Issues 0
  • Merge Requests 0
  • Wiki
  • Network
  • Create a new issue
  • Builds
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Network
  • Compare
  • Branches
  • Tags
Switch branch/tag
  • part_of_F3_OCR
  • async_test
  • server1.py
  • 周伟奇's avatar
    add async test · a33165ce
    周伟奇 committed 2022-07-14 11:01:17 +0800
    a33165ce Browse Files
server1.py 401 Bytes
Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
import asyncio
import time

from sanic import Sanic
from sanic.response import json

app = Sanic("async_test")


@app.get("/sync")
async def sync_handler(request):
    time.sleep(2)
    return json({'code': 1})


@app.get("/async")
async def async_handler(request):
    await asyncio.sleep(2)
    return json({'code': 1})


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=1337, workers=5)