commit 7735f76b4850a6ab87ab0ac16ef4a3d25b8c01ef
parent af48387155ff2508b48b13717f1ecdc8eddba379
Author: parazyd <parazyd@dyne.org>
Date: Wed, 3 May 2017 03:02:39 +0200
pep8
Diffstat:
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/blck.py b/blck.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python
# copyleft (c) 2017 - parazyd
# see LICENSE file for details
@@ -10,6 +10,7 @@ import string
app = flask.Flask(__name__)
+
@app.route("/", methods=['GET', 'POST'])
def main():
try:
@@ -18,6 +19,7 @@ def main():
except:
return flask.render_template("index.html")
+
@app.route("/<urlshort>")
def u(urlshort):
try:
@@ -37,7 +39,7 @@ def s(url):
## taken from django
regex = re.compile(
r'^(?:http|ftp)s?://' # http:// or https://
- r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
+ r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'
r'localhost|' #localhost...
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
r'(?::\d+)?' # optional port
@@ -54,7 +56,8 @@ def s(url):
return "could not save url\n"
if flask.request.headers.get('X-Forwarded-Proto') == 'https':
- return flask.request.url_root.replace('http://', 'https://') + urlshort + '\n'
+ return flask.request.url_root.replace('http://', 'https://') \
+ + urlshort + '\n'
return flask.request.url_root + urlshort + '\n'