diff --git a/config.example.hy b/config.example.hy index d9e945c..b606d2f 100644 --- a/config.example.hy +++ b/config.example.hy @@ -17,3 +17,8 @@ (def *dbuser* "") ; User to log in with (def *dbpw* "") ; Password to log in with (def *dbname* "") ; Database to use + +;; Prefix to use when running. This option should contain a trailing +;; `/'. An example would be: if you're running this project under +;; http://example.com/hypo/ you should use "hypo/". +(def *prefix* "") diff --git a/hypo.hy b/hypo.hy index 1ebadbb..e27b62a 100755 --- a/hypo.hy +++ b/hypo.hy @@ -27,10 +27,10 @@ (sys.exit 1))) (def render (web.template.render "templates/")) -(def urls (, "/raw/(.*)" "raw" - "/dl/(.*)" "download" - "/([a-f0-9]{7})$" "html" - "/(.*)" "upload")) +(def urls (, (+ "/" *prefix* "raw/(.*)") "raw" + (+ "/" *prefix* "dl/(.*)") "download" + (+ "/" *prefix* "([a-f0-9]{7})$") "html" + (+ "/" *prefix* "(.*)") "upload")) (def db (kwapply (web.database) {"dbn" "postgres" "user" *dbuser* "pw" *dbpw* "db" *dbname*})) @@ -127,7 +127,7 @@ "filename" name "type" (get-type (get (os.path.splitext name) 1))}) (setv web.ctx.status "201 Created") - (+ web.ctx.home "/" (get h 0) "\n")))]]) + (+ web.ctx.home "/" *prefix* (get h 0) "\n")))]]) (when (= __name__ "__main__") (let ((sys.argv (slice sys.argv 1))