From bdda215b53b53b89844e0b4c0890fd896fb2443a Mon Sep 17 00:00:00 2001 From: Dmitry Ponyatov Date: Thu, 9 Jul 2020 12:30:58 +0400 Subject: [PATCH] + web.py (async system browser) Signed-off-by: Dmitry Ponyatov --- Makefile | 2 +- web.py | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 web.py diff --git a/Makefile b/Makefile index 41314ab..4dedc9d 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,7 @@ static/bootstrap.js: .PHONY: master shadow release MERGE = Makefile README.md .gitignore .vscode apt.txt requirements.txt -MERGE += $(MODULE).py test_$(MODULE).py $(MODULE).ini static templates config.py +MERGE += $(MODULE).py test_$(MODULE).py $(MODULE).ini web.py static templates config.py master: git checkout $@ diff --git a/web.py b/web.py new file mode 100644 index 0000000..4bc3bbd --- /dev/null +++ b/web.py @@ -0,0 +1,39 @@ +# web client (async viever) + +import os, sys +import config + +from metaL import * + +import flask + +app = flask.Flask(__name__) + +@app.route('/') +def index(): + return flask.render_template('index.html', vm=vm, ctx=vm) + +@app.route('/.png') +def png(path): + return app.send_static_file(path + '.png') +@app.route('/.jpg') +def jpg(path): + return app.send_static_file(path + '.jpg') + +@app.route('/.css') +def css(path): + return app.send_static_file(path + '.css') +@app.route('/.js') +def js(path): + return app.send_static_file(path + '.js') + +@app.route('/') +def path(path): + ctx = vm + for i in path.split('/'): + ctx = ctx[i] + return flask.render_template('index.html', vm=vm, ctx=ctx) + + +app.run(host=config.HTTP_IP, port=config.HTTP_PORT, + debug=True, extra_files=sys.argv)