Output BottlePy Routes
Tuesday, March 27th, 2012 | Programming, Web Application, Work
To quickly get a list of routes in a Bottle wsgi application you will first need to add this method to the Bottle class in bottle.py:
def get_routes(self): """ Returns all the routes """ return self.routes
This merely exposes the route objects.
In my main.py I’ve split up the project into several Bottle objects in different module files and mounted them to the default application.
import file_requests mount('/file', file_requests.app)
Now for the actual output function:
def display_routes(prefix, app): for route in app.get_routes(): print route.method + " " + prefix + route.rule
Then all we need to do is call that function using the correct prefix and application (ie what was used for mount):
# if any routes are in the default_app display_routes("", default_app()) # display file request routes display_routes("/file", file_requests.app)
It will output something like this:
ANY /file/:#.*# ANY /file POST /file/ GET /file/<file_id> POST /file/<file_id>
Categories
Archive
- July 2012
- April 2012
- March 2012
- February 2012
- January 2012
- October 2011
- June 2011
- February 2011
- January 2011
- November 2010
- October 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- October 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
Links
- A Joke A Day
- Asari – Search and Store
- Australian Gamer
- Cracked.com
- Flickering Creations Candles
- FlipCode
- Gamasutra
- Game Developer’s Conference
- Games Industry Biz
- Games Job News
- GameTentacle
- Glest
- Glest Forums

- Independant Games Festival
- Indie Game Jobs
- Jokes Warehouse
- Kat Skinner
- Nathan Reus – Computer Repair
- One Liner Jokes
- Plugins
- Queensland Games
- Stackoverflow – Programmer Jokes
- Support Forum
- Themes
- True Free Host