-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserve_slides.py
44 lines (33 loc) · 1.05 KB
/
serve_slides.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import sys
from aiohttp import web
import subprocess as sp
routes = web.RouteTableDef()
FILENAME = 'reveal/reveal.js-3.6.0/index.html'
if len(sys.argv) > 1:
FILENAME = f'reveal/reveal.js-3.6.0/{sys.argv[1]}'
@routes.get('/')
async def handle(request):
return web.FileResponse(FILENAME)
@routes.post('/runprog')
async def runprog(request):
data = await request.json()
print(data)
if 'cmd' in data:
fname = data['cmd']
sp.Popen(
f'python -m {fname}'.split(),
)
return web.Response()
app = web.Application()
# app.router.add_static('/', 'reveal/reveal.js-3.6.0/')
app.router.add_static('/js', 'reveal/reveal.js-3.6.0/js')
app.router.add_static('/css', 'reveal/reveal.js-3.6.0/css')
app.router.add_static('/img', 'reveal/reveal.js-3.6.0/img')
app.router.add_static('/lib', 'reveal/reveal.js-3.6.0/lib')
app.router.add_static('/plugin', 'reveal/reveal.js-3.6.0/plugin')
app.router.add_routes(routes)
# app.add_routes([
# web.get('/', handle),
# ])
print('Serving on http://localhost:8080')
web.run_app(app)