Permalink
Browse files

Use the server port as well when constructing a full path.

  • Loading branch information...
1 parent 4aabd83 commit 1477ffc0d93eb97bd675c9cf1b615bd18c2285af @bjandras bjandras committed Jul 1, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 objavi/cgi_utils.py
View
@@ -90,6 +90,7 @@ def url2path(url):
_htdocs = os.path.abspath(config.HTDOCS)
SERVER_NAME = os.environ.get('SERVER_NAME', 'localhost')
+SERVER_PORT = os.environ.get('SERVER_PORT', '80')
def path2url(path, default='/missing_path?%(path)s', full=False):
"""convert local file paths to htdocs-relative addresses. If the
@@ -102,7 +103,7 @@ def path2url(path, default='/missing_path?%(path)s', full=False):
else:
path = default % {'path': urllib.quote(path)}
if full:
- return 'http://%s%s' % (SERVER_NAME, path)
+ return 'http://%s:%s%s' % (SERVER_NAME, SERVER_PORT, path)
return path

0 comments on commit 1477ffc

Please sign in to comment.