【发布时间】:2017-04-13 18:19:40
【问题描述】:
下面是一个简单的aiohttp服务器代码,我想知道如何在服务器的响应中返回所有客户端的http请求头信息和服务器响应http头信息。
一个简单的目标是当我使用网络浏览器打开http://127.0.0.1:8080时,网页可以立即显示客户端的http请求头和服务器响应的http头。
感谢任何帮助。
from aiohttp import web
async def handle(request):
request_head = web.Request.headers //Q1?
response_head = web.Response.headers //Q2?
return web.Response("\n".join((request_head,response_head)))
app = web.Application()
app.router.add_get('/', handle)
web.run_app(app)
【问题讨论】: