py2 and py3 support
This commit is contained in:
parent
5a0beb1a75
commit
9e7ca474cd
1 changed files with 7 additions and 3 deletions
|
@ -1,7 +1,11 @@
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import urllib
|
# Support python2 and python3 quote import
|
||||||
|
try:
|
||||||
|
from urllib import quote, unquote
|
||||||
|
except ImportError:
|
||||||
|
from urllib.parse import quote, unquote
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import redis
|
import redis
|
||||||
|
@ -166,7 +170,7 @@ def handle_password():
|
||||||
base_url = request.url_root
|
base_url = request.url_root
|
||||||
else:
|
else:
|
||||||
base_url = request.url_root.replace("http://", "https://")
|
base_url = request.url_root.replace("http://", "https://")
|
||||||
link = base_url + urllib.quote(token)
|
link = base_url + quote(token)
|
||||||
return render_template('confirm.html', password_link=link)
|
return render_template('confirm.html', password_link=link)
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,7 +178,7 @@ def handle_password():
|
||||||
def show_password(password_key):
|
def show_password(password_key):
|
||||||
if not request_is_valid(request):
|
if not request_is_valid(request):
|
||||||
abort(404)
|
abort(404)
|
||||||
password_key = urllib.unquote(password_key)
|
password_key = unquote(password_key)
|
||||||
password = get_password(password_key)
|
password = get_password(password_key)
|
||||||
if not password:
|
if not password:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
Loading…
Reference in a new issue