-
Notifications
You must be signed in to change notification settings - Fork 0
/
server1.py
29 lines (20 loc) · 876 Bytes
/
server1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import asyncio
from aiohttp import web
#import math
from libs.PositionGenerator import PositionGenerator
from libs.helpers import *
async def calc(request):
args = request.query
generator = PositionGenerator(int(args['mult1']),int(args['mult1']))
generator.generate(int(args['from']), int(args['to']))
positions = unzip_positions(generator.get_generated())
return web.Response(body=str(positions) + '<br><a href="/">Back</a>', content_type='text/html')
async def handler(request):
f = open('html/form.html', encoding='utf8')
return web.Response(text=f.read(), content_type='text/html', charset='utf-8')
loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
app = web.Application(loop=loop)
app.router.add_route('GET', '/calc', calc)
app.router.add_route('GET', '/', handler)
web.run_app(app, host='localhost', port=80)