diff --git a/pypiserver/core.py b/pypiserver/core.py index f010e4f..c03d7c0 100755 --- a/pypiserver/core.py +++ b/pypiserver/core.py @@ -1,7 +1,7 @@ #! /usr/bin/env python """minimal PyPI like server for use with pip/easy_install""" -import os, sys, getopt, re, mimetypes +import os, sys, getopt, re, mimetypes, urlparse from pypiserver import bottle, __version__ sys.modules["bottle"] = bottle @@ -94,15 +94,15 @@ def root():

To use this server with pip, run the the following command:

-pip install -i %(URL)ssimple PACKAGE [PACKAGE2...]
+pip install -i %(URL)ssimple/ PACKAGE [PACKAGE2...]
 

To use this server with easy_install, run the the following command:

-easy_install -i %(URL)ssimple PACKAGE
+easy_install -i %(URL)ssimple/ PACKAGE
 

-

The complete list of all packages can be found here or via the /simple index.

+

The complete list of all packages can be found here or via the simple index.

This instance is running version %(VERSION)s of the pypiserver software.

@@ -110,24 +110,28 @@ easy_install -i %(URL)ssimple PACKAGE @route("/simple") +def simpleindex_redirect(): + return redirect(request.fullpath + "/") + + @route("/simple/") def simpleindex(): prefixes = list(packages.find_prefixes()) prefixes.sort() res = ["Simple Index\n"] for x in prefixes: - res.append('%s
\n' % (x, x)) + res.append('%s
\n' % (x, x)) res.append("") return "".join(res) @route("/simple/:prefix") -def simple_redirect(prefix): - return redirect("/simple/%s/" % prefix) - - @route("/simple/:prefix/") def simple(prefix=""): + fp = request.fullpath + if not fp.endswith("/"): + fp += "/" + files = packages.find_packages(prefix) if not files: if config.redirect_to_fallback: @@ -137,7 +141,9 @@ def simple(prefix=""): res = ["Links for %s\n" % prefix] res.append("

Links for %s

\n" % prefix) for x in files: - res.append('%s
\n' % (x, os.path.basename(x))) + abspath = urlparse.urljoin(fp, "../../packages/%s" % x) + + res.append('%s
\n' % (abspath, os.path.basename(x))) res.append("\n") return "".join(res) @@ -145,11 +151,15 @@ def simple(prefix=""): @route('/packages') @route('/packages/') def list_packages(): + fp = request.fullpath + if not fp.endswith("/"): + fp += "/" + files = packages.find_packages() files.sort() res = ["Index of packages\n"] for x in files: - res.append('%s
\n' % (x, x)) + res.append('%s
\n' % (urlparse.urljoin(fp, x), x)) res.append("\n") return "".join(res) @@ -165,7 +175,14 @@ def server_static(filename): @route('/:prefix') @route('/:prefix/') def bad_url(prefix): - return redirect("/simple/%s/" % prefix) + p = request.fullpath + if not p.endswith("/"): + p += "/" + p += "../simple/%s/" % prefix + + return redirect(p) + + # return redirect("../simple/%s/" % prefix) def usage():