JS Problems geeksforgeeks Exercises and Solutions for Beginners

How to Start an HTTP Server in Python [All Method]️

The blog is about How to Start an HTTP Server in Python & provides a lot of information to the novice user and the more seasoned user. By following this guide, you will be able to deal with these sorts of difficulties.
Question: What is the best way to approach this problem? Answer: Check out this blog code to learn how to fix errors How to Start an HTTP Server in Python. Question: “What should you do if you run into code errors?” Answer:”You can find a solution by following this blog.

What’s the easiest way we can start a local HTTP server in Python?

Once we’re in the terminal at the root directory of our application, we can execute either of these commands, depending on the Python version.

# Python 2
python -m SimpleHTTPServer 8000
# Python 3
python -m http.server 8000

Then, our files will be served from http://localhost:8000/.

For the most part, we can use any port we’d like (not just 8000). On Linux, we’ll find that ports below 1024 are privileged ports, meaning the applications listening on these ports should be privileged. They should run as root or have the CAP_NET_BIND_SERVICE capability.

So, most ports above 1024 are fair game.


Revise the code and make it more robust with proper test case and check an error there before implementing into a production environment.
Final Note: Try to Avoid this type of mistake(error) in future!

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button