archive
/
lantern
Archived
1
Fork 0

Run simple test handle

This commit is contained in:
Jake Howard 2017-04-11 13:34:09 +01:00
parent 5cbc5a8c35
commit e6f63a22a3
3 changed files with 12 additions and 3 deletions

View File

@ -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
)

View File

@ -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))

5
lantern/test_handle.py Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env python3
# Test handler
print("<h1>Test</h1>")