Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SimpleHTTPServer not found python3

I'm trying to write a simple server in python. I'm trying to import a few modules:

from http.server import HTTPServer
from http.server import SimpleHTTPServer

Because the doc says it has been moved.

But it gives me this error : from http.server import SimpleHTTPServer ImportError: cannot import name 'SimpleHTTPServer'

And without SimpleHTTPServer I can't use SimpleHTTPRequestHandler, as it is defined in SimpleHTTPServer.SimpleHTTPRequestHandler.

like image 758
Danial Avatar asked Dec 03 '25 09:12

Danial


1 Answers

The SimpleHTTPServer module was moved to be the module http.server. So the command is:

python3 -m http.server

Also, the new SimpleHTTPRequestHandler object is BaseHTTPRequestHandler.

like image 188
rassar Avatar answered Dec 05 '25 02:12

rassar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!