Official documentation example.
import http.server
import socketserver
port=8000
handl=http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(('127.0.0.1',port),handl) as httpd:
print('sering st port',port)
httpd.serve_forever()
As shown in the figure, if there is index.html in it, the index.html page will be displayed directly