6-315/www/app.py

32 lines
766 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import logging; logging.basicConfig(level=logging.INFO)
# logging是Python 的日志记录工具level表示设置根记录器级别去指定 level.
# 日志级别:
# CRITICAL 50
# ERROR 40
# WARNING 30
# INFO 20
# DEBUG 10
# NOTSET 0
# 导入 logging 模块并使用';'对其全局配置
# basicConfig 配置了 level 信息level 配置为 INFO 信息,即只输出 INFO 级别的信息
import asyncio
from aiohttp import web
async def index(request):
return web.Response(body=b'<h1>fuck</h1>', headers={'content-type': 'text/html'})
def init():
# 创建 web.Application ,web app的骨架
app = web.Application()
app.router.add_get('/', index)
web.run_app(app, host='127.0.0.1', port=9000)
if __name__ == '__main__':
init()