Miscellaneous
HTTP Endpoints for easy testing of your app.
Built with the FastAPI Framework for Python, this is heavily based on the original Httpbin website.
Play with it in production at https://httpbin.dmuth.org/ Documentation for all endpoints is right on the front page of the site. What are you waiting for? :-)
Also consider these add-ons I wrote which make use of the API:
/cache
endpoints in Httpbin.GET
version only, as I did not see the point to supporting every possible HTTP verb--I felt that this just made the Swagger documentation unwieldly. (This is subject to change based on usage patters and demand)To run FastAPI Httpbin in development mode so that changes to the underlying Python files are automatically reloaded:
pip install -r ./requirements.txt
PORT=9000 ./bin/dev.sh
- Run server in dev mode on port 9000, so that changes to the Python scripts cause them to be reloaded./bin/docker-build.sh
./bin/docker-dev.sh
/mnt/
.
cd /mnt
./pytest.sh
./pytest.sh -v
to view individual test names as they run./pytest.sh -k NAME
to limit tests to a specific test by name./bin/dev.sh
, however changes to files may not be caught.
requirements.txt
./bin/docker-build.sh && ./bin/docker-dev.sh
cd /mnt
./pytest.sh -v
pip freeze > ./requirements.txt
./lib/fastapi.py
../bin/docker-build.sh
./bin/deploy.sh
fly deploy
to deploy the container on Fly.io../bin/docker-push.sh
./bin/prod.sh
- Run in production mode, so that changes made to the Python scripts do NOT cause reloads../bin/docker-prod.sh
- Run the Docker container in production mode (detached from the console).Look in k8s/README.md for Kubernetes instructions. I built that out using k3s with k3d, but those files should work reasonably well in a full blown k8s environment.
If you are running Docker from Vagrant, the app won't behave right when run in Development Mode inside of a container. Specifically, the functionality of FastAPI to reload itself when a file is changed does not seem to work. For now, the workaround is to restart the FastAPI server when new changes are to be tested, or to not run it in a container in the first place.
Production use is unaffected.
If you run into any problems, feel free to open an issue.
Otherwise, you can find me on Twitter, Facebook, or drop me an email: doug.muth AT gmail DOT com.