通过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)