Thoughts on Tech

My API Server

This project is to produce a simple API server I can run locally with persistence because frankly the ones offered online are useless for serious testing and learning. This was done and run on LMDE and I was using HTTPie as my API client.

With this done, shut everything down and, for the sake of clarity, start from scratch. This is all in a terminal. So:

  • Navigate into your project folder, and activate your venv, thus: source venv/bin/activate
  • Then start the server: python -m uvicorn main:app --reload — your server will start.
  • http POST http://127.0.0.1:8000/todos id:=1 title="This a Test" — this will post an item to your server.
  • Then run this command: http GET http://127.0.0.1:8000/todos — you should see what you've just posted.
  • Or you could just paste the URL into a browser tab: http://127.0.0.1:8000/todos

    That's it. You're done. You now have a useful API server with persistence you can expand upon and use for testing (NB: I used JSON as the fastest route to persistence; I know this doesn't scale).