Created
August 30, 2021 21:58
-
-
Save blacktrub/82e2c95e7c30c801eb55cae6e642d3f8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # 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