Skip to content

Instantly share code, notes, and snippets.

@tomotaka
Created June 4, 2016 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tomotaka/24b667b048aa1a08296b39942c9c064d to your computer and use it in GitHub Desktop.
Save tomotaka/24b667b048aa1a08296b39942c9c064d to your computer and use it in GitHub Desktop.
get url, query string, path in bottle
import bottle
from wsgiref import simple_server
b = bottle.Bottle()
def test():
path = bottle.request.path
urlargs = bottle.request.url_args
query_string = bottle.request.query_string
url = bottle.request.url
return 'your path = %s, urlargs=%s, qs=%s, url=%s' % (path, urlargs, query_string, url)
b.route('/', ['GET'], test)
sv = simple_server.make_server('', 8080, b)
sv.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment