eth0.pro

Linux is working. The future is open.



Фильтр по тегу: python

Web-сервер:

#!/usr/bin/env python3.7


import asyncio
from aiohttp import web

import logging


HOST = "127.0.0.1"
PORT = 4001


async def test(request):
	data = await request.post()
	res = {
		"test":	True
	}
	return web.json_response(res)


async def init(loop):
	pass


def main():
	loop = asyncio.get_event_loop()
	loop.run_until_complete(init(loop))

	app = web.Application()

	app.add_routes([
		web.post('/test', test),
	])

	web.run_app(app, host=HOST, port=PORT)


if __name__ == "__main__":
	logging.basicConfig(level=logging.DEBUG)
	# logging.basicConfig(level=logging.INFO)

	main()

12 мар 2020 г. | Теги: python