Skip to content

Instantly share code, notes, and snippets.

@blacktrub
Created August 30, 2021 21:58
Show Gist options
  • Select an option

  • Save blacktrub/82e2c95e7c30c801eb55cae6e642d3f8 to your computer and use it in GitHub Desktop.

Select an option

Save blacktrub/82e2c95e7c30c801eb55cae6e642d3f8 to your computer and use it in GitHub Desktop.
# install dependencies
pip install requests bottle
# server.py
import json
from bottle import run, response, post
@post("/test")
def index():
response.headers["Content-Type"] = "application/json"
return json.dumps({"foo": "bar"})
run(host="localhost", port=8080)
# run server
python server.py
# check
>>> import requests
>>> response = requests.post('http://localhost:8080/test')
>>> response.json()
{'foo': 'bar'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment