From 31b26a2e919a988b2a8e33ebebee0617b85b51e7 Mon Sep 17 00:00:00 2001 From: Eidenz Date: Mon, 13 Dec 2021 09:57:46 +0100 Subject: [PATCH 1/5] update(web_main.py) added Google & DeepL engines --- web_main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_main.py b/web_main.py index f22f02971..e084412f7 100644 --- a/web_main.py +++ b/web_main.py @@ -57,7 +57,7 @@ async def run_async(request): target_language = 'CHS' if 'translator' in data : selected_translator = data['translator'].lower() - if selected_translator not in ['youdao', 'baidu', 'null'] : + if selected_translator not in ['youdao', 'baidu', 'google', 'deepl', 'null'] : selected_translator = 'youdao' if 'size' in data : size = data['size'].upper() @@ -211,7 +211,7 @@ async def submit_async(request): target_language = 'CHS' if 'translator' in data : selected_translator = data['translator'].lower() - if selected_translator not in ['youdao', 'baidu', 'null'] : + if selected_translator not in ['youdao', 'baidu', 'google', 'deepl', 'null'] : selected_translator = 'youdao' if 'size' in data : size = data['size'].upper() From 2411450cbaaa1034f9232f3a00d1c6330b5d44f2 Mon Sep 17 00:00:00 2001 From: Eidenz Date: Mon, 13 Dec 2021 10:00:11 +0100 Subject: [PATCH 2/5] feat(web_main.py) added result route to return final image --- web_main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web_main.py b/web_main.py index e084412f7..041b01af2 100644 --- a/web_main.py +++ b/web_main.py @@ -45,6 +45,13 @@ async def index_async(request): with open('ui.html', 'r') as fp : return web.Response(text=fp.read(), content_type='text/html') +@routes.get("/result/{taskid}") +async def result_async(request): + im = Image.open("result/" + request.match_info.get('taskid') + "/final.png") + stream = BytesIO() + im.save(stream, "PNG") + return web.Response(body=stream.getvalue(), content_type='image/png') + @routes.post("/run") async def run_async(request): data = await request.post() From 005cdc47936f345bd02e3e314f9a99e9e70d2461 Mon Sep 17 00:00:00 2001 From: Eidenz Date: Mon, 13 Dec 2021 10:01:57 +0100 Subject: [PATCH 3/5] update(ui.html) removed extra part of url for new result route --- ui.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui.html b/ui.html index d6f7418e9..a2b7194a8 100644 --- a/ui.html +++ b/ui.html @@ -147,7 +147,7 @@ if (STATE !== "error") { document.getElementById("translated-image-div").style.visibility = ""; document.getElementById("translated-image").src = ""; - document.getElementById("translated-image").src = BASE_URI + "result/" + TASKID + "/final.jpg"; + document.getElementById("translated-image").src = BASE_URI + "result/" + TASKID; } status.innerHTML = ''; ProgressBar.end(); @@ -489,4 +489,4 @@

Translated image

ease: 'ease' // DEFAULT, YOU CAN SKIP IT }); - \ No newline at end of file + From 345a4bc4b2adf65cc47acc159f79aa2a9752eb2b Mon Sep 17 00:00:00 2001 From: Eidenz Date: Mon, 13 Dec 2021 10:04:06 +0100 Subject: [PATCH 4/5] fix(web_main.py) added missing library for new result route --- web_main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/web_main.py b/web_main.py index 041b01af2..aa153f8e3 100644 --- a/web_main.py +++ b/web_main.py @@ -10,6 +10,7 @@ from oscrypto import util as crypto_utils from aiohttp import web from aiohttp import ClientSession +from io import BytesIO from collections import deque From d5f29b8fe58737bd41d8c1f5fc6ed53aa7883716 Mon Sep 17 00:00:00 2001 From: Eidenz Date: Mon, 13 Dec 2021 10:46:54 +0100 Subject: [PATCH 5/5] update(ui.html) added missing Google & DeepL radio buttons --- ui.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui.html b/ui.html index a2b7194a8..21cddf3f2 100644 --- a/ui.html +++ b/ui.html @@ -213,6 +213,14 @@

Image/Manga translator

Baidu + +
Target language: