Skip to content

Commit f6863f4

Browse files
committed
Become Python 3 only
* Run flynt --upgrade to modernize things
1 parent 60275f2 commit f6863f4

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This is a Python 2.x WSGI version of https://github.com/fehmicansaglam/progressed.io, so all credit
1+
This is a Python 3.x WSGI version of https://github.com/fehmicansaglam/progressed.io, so all credit
22
for the idea and original implementation is due to Fehmi Can Sağlam.
33

44
I wrote it as a little snack of sorts, but it may be useful for understanding how to write very simple

progressed.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
# -- encoding: UTF-8 --
2-
31
import re
42
import sys
53

6-
SVG_TEMPLATE = u"""
4+
SVG_TEMPLATE = """
75
<svg height="18" width="90" xmlns="http://www.w3.org/2000/svg">
86
<linearGradient id="a" x2="0" y2="100%%">
97
<stop offset="0" stop-color="#fff" stop-opacity=".7"/>
@@ -51,18 +49,15 @@ def simple_response(start_response, content, status_line="200 OK",
5149
:param content_type: The content type header. Defaults to UTF-8 HTML.
5250
:return: An iterable of content ready to be returned to the WSGI server.
5351
"""
54-
if (sys.version_info > (3, 0)):
55-
content = str(content).encode("UTF-8")
56-
else:
57-
content = unicode(content).encode("UTF-8")
52+
content = str(content).encode("UTF-8")
5853
start_response(status_line, [
5954
("Content-Length", str(len(content))),
6055
("Content-Type", content_type)
6156
])
6257
return [content]
6358

6459

65-
BAR_PATH_RE = re.compile("^/bar/(\d+)$")
60+
BAR_PATH_RE = re.compile(r"^/bar/(\d+)$")
6661

6762

6863
def application(environ, start_response):
@@ -82,10 +77,10 @@ def application(environ, start_response):
8277
content_type="image/svg+xml"
8378
)
8479
elif path == "/ping":
85-
return simple_response(start_response, u"pong")
80+
return simple_response(start_response, "pong")
8681
else:
8782
return simple_response(
88-
start_response, u"Not found.", status_line="404 Not Found")
83+
start_response, "Not found.", status_line="404 Not Found")
8984

9085

9186
def standalone():

0 commit comments

Comments
 (0)