Skip to content

Instantly share code, notes, and snippets.

@waynew

waynew/server.py

Created Aug 3, 2016
Embed
What would you like to do?
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
You can’t perform that action at this time.