您当前的位置: 首页 >  服务器

Python编程:aiohttp库服务器端简单使用

彭世瑜 发布时间:2018-06-21 17:53:40 ,浏览量:2

通过flask和aiohttp对比着来看

flask

http://docs.jinkan.org/docs/flask/

from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == '__main__':
    app.run()
aiohttp

aiohttp是基于asyncio实现的HTTP框架 http://aiohttp.readthedocs.io/en/stable/index.html


from aiohttp import web

routes = web.RouteTableDef()

@routes.get('/')
async def hello(request):
    return web.Response(text="Hello, world")

app = web.Application()
app.add_routes(routes)
web.run_app(app)
关注
打赏
1688896170
查看更多评论

彭世瑜

暂无认证

  • 2浏览

    0关注

    2727博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0610s