Skip to content

Instantly share code, notes, and snippets.

@leotada
Created June 26, 2019 19:23
Show Gist options
  • Save leotada/4727223d8aafb284d56034ccc7dfbc37 to your computer and use it in GitHub Desktop.
Save leotada/4727223d8aafb284d56034ccc7dfbc37 to your computer and use it in GitHub Desktop.
Bottle Python example of dynamic mock
from bottle import run, request, get, post, response
@get('/<full_url:path>')
def index(full_url):
if full_url == 'test':
return 'cool'
elif full_url == 'double':
return 'triple'
else:
return full_url
@post('/<full_url:path>')
def index2(full_url):
response.content_type = 'application/json'
return request.body
run(host='localhost', port=8080)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment