python - WSGI with python3 not working -


i'm trying run python on web css/jss extraction websites. i'm using mod_wsgi interface python. i've been following this website idea on getting started. below sample code.

#! /usr/bin/env python  # our tutorial's wsgi server wsgiref.simple_server import make_server  def application(environ, start_response):     # sorting , stringifying environment key, value pairs    response_body = ['%s: %s' % (key, value)                     key, value in sorted(environ.items())]    response_body = '\n'.join(response_body)     status = '200 ok'    response_headers = [('content-type', 'text/plain'),                   ('content-length', str(len(response_body)))]    start_response(status, response_headers)     return [response_body]  # instantiate wsgi server. # receive request, pass application # , send application's response client httpd = make_server(    'localhost', # host name.    8051, # port number wait request.    application # our application object name, in case function.    )  # wait single request, serve , quit. httpd.handle_request() 

while runs fine python 2.7, can't run on python 3. css/jss extraction, have modified above code , put in own functionalities use beautifulsoup , urllib3. while using modules need python 3, wsgi code need python 2.7. hence, can't merge two. when trying run bs , urllib in python3, error. when try run wsgi code python3, i'm unable load webpage.

any appreciated! workarounds, or suggestions well.


Comments