Skip to content

Commit 76c88d2

Browse files
committed
App cleanup
1 parent 0324794 commit 76c88d2

File tree

10 files changed

+169
-534
lines changed

10 files changed

+169
-534
lines changed

app/server.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import asyncio
2-
import mimetypes
3-
4-
import aiohttp
52
import yaml
63
from os.path import join, dirname
74
from aiohttp import web
@@ -20,19 +17,8 @@ def run_playbook(data):
2017
global task_program
2118
extra_vars = ' '.join(['{0}={1}'.format(key, data[key]) for key in data.keys()])
2219
task_program = ['ansible-playbook', 'main.yml', '--extra-vars', extra_vars]
23-
vars = PlaybookCLI(task_program).run()
24-
# TODO: filter only necessary vars
25-
return vars
26-
27-
@routes.get('/static/{path}')
28-
async def handle_static(request):
29-
filepath = request.match_info['path']
30-
mimetype = mimetypes.guess_type(filepath)
31-
try:
32-
with open(join(dirname(__file__), 'static', *filepath.split('/')), 'r') as f:
33-
return web.Response(body=f.read(), content_type=mimetype[0])
34-
except FileNotFoundError:
35-
return web.Response(status=404)
20+
return PlaybookCLI(task_program).run()
21+
3622

3723
@routes.get('/')
3824
async def handle_index(_):
@@ -102,4 +88,6 @@ async def post_config(request):
10288

10389
app = web.Application()
10490
app.router.add_routes(routes)
91+
app.add_routes([web.static('/static', join(PROJECT_ROOT, 'app', 'static'))])
92+
app.add_routes([web.static('/results', join(PROJECT_ROOT, 'configs'))])
10593
web.run_app(app, port=9000)

0 commit comments

Comments
 (0)