~metalune/public-inbox

simplytranslate_web: Adding Cookies v1 PROPOSED

Esmail Almaleeh: 1
 simplytranslate_web: Adding Cookies

 1 files changed, 13 insertions(+), 1 deletions(-)
:)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~metalune/public-inbox/patches/24223/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] simplytranslate_web: Adding Cookies Export this patch

---
 main.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/main.py b/main.py
index 930fbad..f25f2ac 100644
--- a/main.py
+++ b/main.py
@@ -1,4 +1,5 @@
from quart import Quart, render_template, request, redirect
from os import urandom
from quart import Quart, render_template, request, redirect, session
from configparser import ConfigParser
from urllib.parse import urlencode

@@ -34,6 +35,8 @@ if not engines:

app = Quart(__name__)

app.secret_key = urandom(30)

@app.route(
    "/translate/<string:from_language>/<string:to_language>/<string:input_text>/"
)
@@ -129,6 +132,12 @@ async def index():
        from_lang = to_full_name(request.args.get("sl", "auto"), engine)

        to_lang = to_full_name(request.args.get("tl", "en"), engine)

        if session.get('from_language'):
            from_lang = session['from_language']
        if session.get('to_language'):
            to_lang = session['to_language']

    elif request.method == "POST":
        form = await request.form

@@ -138,6 +147,9 @@ async def index():

        to_lang = form.get("to_language", "English")

        session['from_language'] = from_lang
        session['to_language'] = to_lang

    from_l_code = None
    to_l_code = None

-- 
2.25.1
Thank you a lot for this contribution