You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
632 B

from urllib.parse import quote, unquote
def encode_url(text):
return quote(text, safe='')
def decode_url(text):
try:
return unquote(text)
except Exception:
return "解码失败"
def page():
from flask import render_template, request
result = None
input_text = ""
action = request.args.get("action")
text = request.args.get("text", "").strip()
if text:
input_text = text
if action == "decode":
result = decode_url(text)
else:
result = encode_url(text)
return render_template("url.html", result=result, input_text=input_text)