summaryrefslogtreecommitdiff
path: root/homepage/pages/faq.md
diff options
context:
space:
mode:
Diffstat (limited to 'homepage/pages/faq.md')
-rw-r--r--homepage/pages/faq.md49
1 files changed, 49 insertions, 0 deletions
diff --git a/homepage/pages/faq.md b/homepage/pages/faq.md
new file mode 100644
index 0000000..1aa114d
--- /dev/null
+++ b/homepage/pages/faq.md
@@ -0,0 +1,49 @@
+[TOC]
+
+Frequently Asked Questions
+==========================
+
+
+## How to Ignore Tailing Slashes?
+
+Bottle does not ignore tailing slashes by default.
+To handle URLs like `/example` and `/example/` the same,
+you could add two `@route` decorators (fast when using static routes)
+
+ #!Python
+ @route('/test')
+ @route('/test/')
+ def test(): pass
+
+or use dynamic routes
+
+ #!Python
+ @route('/test/?')
+ def test(): pass
+
+or add a WSGI middleware that strips tailing '/' from URLs
+
+ #!Python
+ class StripPathMiddleware(object):
+ def __init__(self, app):
+ self.app = app
+ def __call__(self, e, h):
+ e['PATH_INFO'] = e['PATH_INFO'].rstrip('/')
+ return self.app(e,h)
+
+ app = bottle.default_app()
+ app = StripPathMiddleware(app)
+ bottle.run(app=app)
+
+
+
+
+
+## Apache/mod_python and Template Not Found?
+
+Templates are searched in "./" or "./views/" but Apaches mod_python
+changes your working directory. You can use
+
+ bottle.TEMPLATE_PATH.insert(0,'/absolut/path/to/templates/%s.tpl')
+
+to add an absolute search path.