Skip to content

Instantly share code, notes, and snippets.

@bialecki
Created April 21, 2012 02:05
Show Gist options
  • Save bialecki/2433259 to your computer and use it in GitHub Desktop.
Save bialecki/2433259 to your computer and use it in GitHub Desktop.
'''
Sam Keller
03/11/2012
routeTester.py
This file was written to get to know how bottle.py works and how to write
routes. If we wanted to, say, track which pages are clicked on our Wikipedia
extension for Firefox, this code would be helpful. This simple code just
takes in a Wikipedia page in the address and prints out a little message saying
which page is being tracked (even though no tracking is happening yet).
General help gotten from http://bottlepy.org/docs/dev/tutorial.html
http://localhost:8080/track/page
'''
from bottle import Bottle, run, request, response, get, post
app = Bottle()
@app.route('/track/page')
def trackPages():
url = request.query.url
# the wikiPage is the text that occurs after the "?page=" text in the address
#url = request.forms.get('url')
# print 'wikiPage', wikiPage
return "OK, here's the Wikipedia page that we may be tracking: " + url
# @app.post('/track/page')
# def trackPages():
# url = request.forms.url
# # the wikiPage is the text that occurs after the "?page=" text in the address
# #url = request.forms.get('url')
# # print 'wikiPage', wikiPage
# return "OK, here's the Wikipedia page that we may be tracking: " + url
#
run(app, host='localhost', port=8080)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment