This article will show you very quickly how to use Python as a web server using the 3rd party Flask framework.
Flask is a very easy to use web application framework for writing web servers with Python. It's much easier and offers more features than the native HTTPServer module in Python. It's highly recommended if you plan on writing back end web services or hosting web sites with Python.
You can see how much easier this is compared with the article 'HTTP Web Service'.
from flask import Flask
app = Flask(__name__)
return 'Hello from flask!'
When you run, you will see in the terminal the server running message. While the server is running, open your browser and browse to "http://localhost:81".
You should see a response in your browser that came from your server on line 7.
Explore the Flask framework over at https://flask.palletsprojects.com/en/2.2.x/. I suggest going through the "Quickstart" sections to see what Flask can offer you.