From 117c93deaf64457d4575d24bd21dce5315583827 Mon Sep 17 00:00:00 2001 From: Balakrishnan Balasubramanian Date: Sun, 2 Jul 2023 23:48:04 -0400 Subject: [PATCH] WIP add js to parse and add matches --- jsdev/.gitignore | 1 + jsdev/air.toml | 44 ++++++++++ jsdev/index.html | 130 ++++++++++++++++++++++++++++++ jsdev/restart.sh | 11 +++ mail4one/template_web_config.html | 87 +++++++++++++++++++- mail4one/web_config.py | 11 +-- 6 files changed, 274 insertions(+), 10 deletions(-) create mode 100644 jsdev/.gitignore create mode 100644 jsdev/air.toml create mode 100644 jsdev/index.html create mode 100755 jsdev/restart.sh diff --git a/jsdev/.gitignore b/jsdev/.gitignore new file mode 100644 index 0000000..a9a5aec --- /dev/null +++ b/jsdev/.gitignore @@ -0,0 +1 @@ +tmp diff --git a/jsdev/air.toml b/jsdev/air.toml new file mode 100644 index 0000000..8b76087 --- /dev/null +++ b/jsdev/air.toml @@ -0,0 +1,44 @@ +root = "." +testdata_dir = "testdata" +tmp_dir = "tmp" + +[build] + args_bin = [] + bin = "./tmp/main" + cmd = "cp ./restart.sh ./tmp/main" + delay = 0 + exclude_dir = ["assets", "tmp", "vendor", "testdata"] + exclude_file = [] + exclude_regex = ["_test.go"] + exclude_unchanged = false + follow_symlink = false + full_bin = "" + include_dir = [] + include_ext = ["go", "tpl", "tmpl", "html"] + include_file = [] + kill_delay = "0s" + log = "build-errors.log" + poll = false + poll_interval = 0 + rerun = false + rerun_delay = 500 + send_interrupt = false + stop_on_error = false + +[color] + app = "" + build = "yellow" + main = "magenta" + runner = "green" + watcher = "cyan" + +[log] + main_only = false + time = false + +[misc] + clean_on_exit = false + +[screen] + clear_on_rebuild = false + keep_scroll = true diff --git a/jsdev/index.html b/jsdev/index.html new file mode 100644 index 0000000..6967440 --- /dev/null +++ b/jsdev/index.html @@ -0,0 +1,130 @@ + + + + Mail4one Web config + + + + + +

Mail4one Web config

+ + + + + + + + + + +
NameTypeValues
+ + + diff --git a/jsdev/restart.sh b/jsdev/restart.sh new file mode 100755 index 0000000..af1f6eb --- /dev/null +++ b/jsdev/restart.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# kill "$(cat current.pid)" + +# echo "starting python server" + +python3 -m http.server + +# echo $! > current.pid + +# echo "started python server" diff --git a/mail4one/template_web_config.html b/mail4one/template_web_config.html index a1cde7b..4d5a955 100644 --- a/mail4one/template_web_config.html +++ b/mail4one/template_web_config.html @@ -1,5 +1,88 @@ - Mail4one Web config -

Hello World

+ + Mail4one Web config + + + + + +

Mail4one Web config

+ + + + + + +
NameTypeValues
+ diff --git a/mail4one/web_config.py b/mail4one/web_config.py index 37db4bf..4be69d6 100644 --- a/mail4one/web_config.py +++ b/mail4one/web_config.py @@ -45,17 +45,12 @@ class WebonfigHandler(RequestHandler): userpassb64 = auth_header[len("Basic ") :] try: userpass = b64decode(userpassb64) + username, password = userpass.split(b":") except: logging.exception("bad request") return False, Response.no_body_response(http.HTTPStatus.BAD_REQUEST) - try: - user, passwd = userpass.split(b":") - except: - logging.exception("bad request") - return False, Response.no_body_response(http.HTTPStatus.BAD_REQUEST) - - if user == self.username and check_pass(passwd.decode(), self.pwinfo): + if username == self.username and check_pass(password.decode(), self.pwinfo): return True, None return False, resp_unauthorized() @@ -67,7 +62,7 @@ class WebonfigHandler(RequestHandler): if not ok: if resp: return resp - else: + else: # To silence mypy raise Exception("Something went wrong!") return Response.create_ok_response(get_template())