Video Coming Soon...
Exercise 51: lessweb
We are nearing the end of the book, so I'm going to give you one project in the final two exercises. You are going to create a web server. In this exercise you simply learn about the Python http.server
module and how to create a simple web server using it. You'll be given instructions and then expected to read the documentation to figure out how to do it. There won't be too much guidance as, by now, you should be able to do most everything on your own.
Once you've created your web server you will then write a set of tests to attempt to hack you web server. I'll give you some guidance on this in the Breaking It section, but by now you should be very comfortable in finding flaws in code you write.
Exercise Challenge
You'll need to read the Python 3 http.server documentation to start. You should also read the Python 3 http.client documentation as well as the documentation for Requests. You'll be using either requests
or http.client
to write tests for the http.server
you create.
Next, your job is to create a web server using http.server
that can do the following:
Be configured from a configuration file
Run continuously and handle requests it receives
Serve up files from configured directories
Respond to requests for websites and serve the correct content
Log all requests coming in to a file to read later
If you read the example in the documentation you can probably get most of this working in a basic way. Part of this exercise is how to hack a naive web server, so you should just get it barely working and then we'll move to the next part.
Register for Learn More Python the Hard Way
Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.