diff --git a/lantern/handle.py b/lantern/handle.py index 3addfb9..260bc22 100644 --- a/lantern/handle.py +++ b/lantern/handle.py @@ -12,7 +12,7 @@ def execute_handle(executable, request_data): return Result( cmd.returncode, cmd.stdout.decode('utf-8'), - cmd.stderr.decode('utf-8') + cmd.stderr.decode('utf-8') if cmd.stderr is not None else None ) diff --git a/lantern/route.py b/lantern/route.py index ceed5c1..323b85d 100644 --- a/lantern/route.py +++ b/lantern/route.py @@ -1,5 +1,9 @@ -from sanic.response import json +from sanic.response import html +from lantern.handle import execute_handle, get_http_status_code +import os async def main_route(request, path=None): - return json({"hello": "world"}) + handle = os.path.join(os.path.dirname(__file__), 'test_handle.py') + result = execute_handle(handle, {}) + return html(result.html, status=get_http_status_code(result.exit_code)) diff --git a/lantern/test_handle.py b/lantern/test_handle.py new file mode 100755 index 0000000..e6b9d0b --- /dev/null +++ b/lantern/test_handle.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 + +# Test handler + +print("

Test

")