python http服务器的简单异步包装
asyncbasehttp的Python项目详细描述
异步Http服务器
最简单的异步python http服务器库。在
示例
import asyncio
from asyncbasehttp import request_handler, Request, Response
@request_handler
async def handle_request(req: Request):
return Response.create_ok_response(f'You requested path: {req.path}'.encode())
async def main():
server = await asyncio.start_server(handle_request, port=8000)
print("http://localhost:8000")
await server.serve_forever()
asyncio.run(main())
- 项目
标签: