Created
June 26, 2019 19:23
-
-
Save leotada/4727223d8aafb284d56034ccc7dfbc37 to your computer and use it in GitHub Desktop.
Bottle Python example of dynamic mock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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