by Richard Taylor : 2019-11-05
There is an old joke about a lost traveller who asks a local "Excuse
me. Can you tell me the way to the station?" and the local replies "Oh, if
I was going to the station, I wouldn't start from here."
We always have to start from where we are. I could go off and research the latest API frameworks. But I already have a skeleton application that can stand up an HTTP server with only a few lines of Python code. So I am going to start with that.
The project needs a short working name... and "thelca" doesn't appear to be in wide use, or mean anything offensive. Of course we need source control so here is the thelca project on github and the first significant commit I made.
Notice the following things in that first commit.
A quick description of the project with a link to more detailed documentation. The README is likely to be the first thing people see when they discover your project, so keep it up to date and useful.
One thing I like to put near the top is a section on running the tests. Mainly because having tests is the difference between a professional maintainable project and a quick hack you did one Wednesday afternoon.
Having tests is essential, right from the start of the project. So get off to a good start. Write tests from day 1. Do test-driven-development (TDD) if that works for you. Or write some code and then some tests if you prefer. But always write tests. They pay for themselves many times over.
And make it easy to run the tests. I have wrapped the commands into a simple bash script with a name starting "test" so that I don't have to remember what to type.
The code itself does very little here. But it does do something. There is just enough to show that we have a commitment to writing tests, a test runner, a main program runner and some documentation to get people started easily.
This is enough to show that we have all the moving parts we will need.
Let's see what this bare bones project does so far.
# thelca/bin/test_thelca.sh
test_versions (test_http.TestHTTP) ... ok
------------------------------------------------------------
Ran 1 test in 0.001s
OK
Great. All of the tests pass. So there is a chance the application might start up and do something.
# thelca/bin/run_thelca.sh
2019-11-06 20:00:15,535 INFO Starting a server on port 2207
2019-11-06 20:00:15,561 INFO Entering the server loop
Looks promising. Can we GET anything from that port?
# curl http://localhost:2207/
Hello
Yes we can.
Cool. That's the foundations laid. Now we can build on it.