Run a simple Python HTTP Server

DLM-VM1_Cloud is a self startup distribution platform. We work on multiple open source projects for software companies and open source projects. The two companies that we developed projects for are IBM and Hashicorp. For IBM we built two software projects one using Python the other using Javascript to build a compute server. The server was primarily built to host website and open ports such as tcp. We have nginx load balancer and proxy, HAPROXY, Caddy for reverse proxy and static site web page server. After building the server we then worked on a Hashicorp project. We incorporated the server with a registered IP address to build and contribute to Consul Nomad Vault and Terraform. We listed a DNS and etcd server. Implemented plugins for Ingress Gateway and gRPC proxy ecosystems. Also for etcd we installed node clusters from etcd.io and for hosting. The clusters are built-in to the server we mentioned earlier. To add more to our projects we added Cloudflare to the projects we couldn't wait to work on. We have now teams.Cloudlare a custom DNS with a lot of capabilities. To add we have a zero trust network with policies sending http requests and blocking for security measures. The parameters in which we built the server allowed to add security features to our server with adding clusters and a DNS. I have plans to grow DLM-VM1-Cloud but first have to monitor and grow the basic foundations of this project. If your are interested and want to contribute or build alongside myself or want advice to how I got into tech visit our social sites and reach out. Thanks...
Python HTTP Server
In this tutorial I'll show you a simple yet very easy way to run a http python server. If you haven't already go to https://www.python.org/downloads/ and download the latest version of python. I normally use python 3.8 or better but for those who rather stay up to date with the latest python release, you can download 3.10.0 as you wish. After you download python and the installation is complete, you then have to launch python launcher either into your ide or preferred workspace. There are other alternatives like Visual Studio Code which uses built-in plugins for any language you want to work on.
Make sure you set a local path file and folder when writing code. It's best if you make a directory so that the terminal can properly fetch the destination of the file.
For this http server you don't need to write any code. You can simple start a web development page if you are new to coding. Run the following code into your terminal.
python -m http.server --cgi 8000
This will run an HTTP server on port 8000, serving the files in your current bin folder. If you properly edited the local path to this file you can always go back and edit the file. Once you learn more python code and want to further your development with frameworks, having a python http server would be the best start. If the command runs properly you should have an active directory of files serving localhost:8000
Now if you want to insert modules and string variables you write additional code. But for a first time tutorial use a simple module to print "Hello World":
from http.server import BaseHTTPRequestHandler, HTTPServer
class handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
message = "Hello, World!"
self.wfile.write(bytes(message, "utf8"))
with HTTPServer(('', 8000), handler) as server:
server.serve_forever()
This file should be saved as http.server.py. If the print is successful search more python modules and strings you want to insert into your code file. The python language has a lot of libraries and you can build a variety of different websites, statistical models, computes, games etc. Now that you created your first http server search python frameworks Django, Flask and Jinja as the main popular ones to increase your learning and web development skills. Search more tutorials on YouTube to increase your skills and use different methods to solve problems. Not all codes work the same for developers. Your job is to think the process through and solve how the developer created the site. Thats all for now.
Never Stop Coding (It's a double negative)




