Skip to content

Instantly share code, notes, and snippets.

@waynew
Created August 3, 2016 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waynew/fec9db4d0b3f4e8dfc0d84bd29689889 to your computer and use it in GitHub Desktop.
Save waynew/fec9db4d0b3f4e8dfc0d84bd29689889 to your computer and use it in GitHub Desktop.
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