Created
August 3, 2016 17:58
-
-
Save waynew/fec9db4d0b3f4e8dfc0d84bd29689889 to your computer and use it in GitHub Desktop.
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
import requests | |
from bottle import route, run, template, request | |
@route('/json', method='POST') | |
def fun(): | |
print(request.json) | |
r = requests.post('http://localhost:8890/otherapi', json=request.json) | |
print(r) | |
return 'Ok' | |
@route('/form', method='POST') | |
def form(): | |
name = request.forms.get('name') | |
id = request.forms.get('id') | |
print('Name: {} Id: {}'.format(name, id)) | |
r = requests.post('http://localhost:8890/otherapi', json={'name': name, 'id': id}) | |
print(r) | |
return 'OK' | |
@route('/otherapi', method='POST') | |
def otherapi(): | |
print('Request:', request.json) | |
return | |
import sys | |
if len(sys.argv) > 1: | |
run(host='localhost', port=8889) | |
else: | |
run(host='localhost', port=8890) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment