廖雪峯老師的web開發教程中:
from aiohttp import web
def index(request):
return web.Response(body=b'<h1>Awesome!!!</h1>')
打開對應的網頁總是直接彈出來下載一個文件,而不能直接在網頁上展示字段Awesome!!!,後來在index函數中的body上加上以下content_type即可。
def index(request):
return web.Response(body=b'<h1>Awesome!!!</h1>',content_type='text/html')