九州体育网 - 十年信誉网站

关于作者

Discuss / Python / 哈哈哈

哈哈哈

Topic source

drzdryse不放弃

#1 Created at ...

先运行再在网页上造访http://127.0.0.1:9000

import logging; logging.basicConfig(level=logging.INFO)

import asyncio, os, json, time from datetime import datetime

from aiohttp import web

def index(request): return web.Response(body='<h1>Awesome</h1>'.encode('utf-8'),content_type='text/html')

@asyncio.coroutine

def init(loop): app = web.Application(loop=loop) app.router.add_route('GET', '/', index) srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', 9000) logging.info('server started at http://127.0.0.1:9000...') return srv

loop = asyncio.get_event_loop() loop.run_until_complete(init(loop)) loop.run_forever()


  • 1

Reply

WARNING: You are using an old browser that does not support HTML5. Please choose a modern browser (Chrome / Microsoft Edge / Firefox / Sarafi) to get a good experience.