A simple Flask application that can be used to test HTTP calls. It simply logs out the request and request data then returns an object with the request information. Useful for debugging HTTP calls to third-party APIs by making the same calls to this server or developing applications locally when you don't want to call real API endpoints.
These instructions will get you a copy of the project up and running on your local machine for development.
First, install dependencies:
$ pipenv install
Creating a virtualenv for this project…
...
Virtualenv location: /Users/user/.virtualenvs/flask-echo-server-zyMB51yv
Installing dependencies from Pipfile.lock (8a3288)…
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 6/6 — 00:00:04
To activate this project's virtualenv, run the following:
$ pipenv shell
Activate the virtual environment:
$ pipenv shell
Spawning environment shell (/bin/zsh). Use 'exit' to leave.
(flask-echo-server-zyMB51yv) $
Run the application:
$ export FLASK_ENV=development; flask run
* Environment: development
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: XXX-XXX-XXX
$ curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST 127.0.0.1:5000/api/v1/test
{
"data": "{\"key1\":\"value1\", \"key2\":\"value2\"}",
"endpoint": "api/v1/test",
"form": {},
"json": {
"key1": "value1",
"key2": "value2"
}
}
Server log:
*** Received data at: api/v1/test
data b'{"key1":"value1", "key2":"value2"}'
form ImmutableMultiDict([])
json {'key1': 'value1', 'key2': 'value2'}
$ curl -d "param1=value1¶m2=value2" -X POST 127.0.0.1:5000/api/v1/test
{
"data": "",
"endpoint": "api/v1/test",
"form": {
"param1": "value1",
"param2": "value2"
},
"json": null
}
Server log:
*** Received data at: api/v1/test
data b''
form ImmutableMultiDict([('param1', 'value1'), ('param2', 'value2')])
json None
Please read CONTRIBUTING.md for details on our code of conduct.
This project is licensed under the MIT License - see the LICENSE file for details.
- 🐙 Cuttlesoft.com
- 🐦 @cuttlesoft
- 📩 hello [at] cuttlesoft [dot] com