no module named http.server

前端 未结 3 1360
南旧
南旧 2021-02-02 10:04

here is my web server class :

import http.server  
import socketserver

class WebHandler(http.server.BaseHTTPRequestHandler):

    def parse_POST(self):
                 


        
相关标签:
3条回答
  • 2021-02-02 10:46

    http.server only exists in Python 3. In Python 2, you should use the BaseHTTPServer module:

    from BaseHTTPServer import BaseHTTPRequestHandler
    

    should work just fine.

    0 讨论(0)
  • 2021-02-02 10:51

    In python earlier than v3 you need to run http server as

    python -m SimpleHTTPServer 8069 
    #(8069=portnumber on which your python server is configured)
    
    0 讨论(0)
  • 2021-02-02 10:52

    like @Sami said: you need earlier versions of python (2.7) - if you're running on Linux you need to "apt install python-minimal" - when launching the server "python2 -m SimpleHTTPServer 8082" [or any other port]. By default, python will launch it on 0.0.0.0 which actually is 127.0.0.1:8082 [or your specific port]

    Happy hacking

    PS when you have 2 versions of python, you need to specify every time you run a command, "python2" or "python3"

    0 讨论(0)
提交回复
热议问题