Setting up Python on Windows/ Apache?

前端 未结 3 1007
夕颜
夕颜 2020-12-29 00:06

I want to get a simple Python \"hello world\" web page script to run on Windows Vista/ Apache but hit different walls. I\'m using WAMP. I\'ve installed mod_python

3条回答
  •  再見小時候
    2020-12-29 00:42

    Stay away from mod_python. One common misleading idea is that mod_python is like mod_php, but for python. That is not true. Wsgi is the standard to run python web applications, defined by PEP 333. So use mod_wsgi instead.

    Or alternatively, use some web framework that has a server. Cherrypy's one is particulary good. You will be able to run your application both standalone and through mod_wsgi.

    An example of Hello World application using cherrypy:

    import cherrypy
    
    class HelloWorld(object):
        def index(self):
            return "Hello World!"
        index.exposed = True
    
    application = HelloWorld()
    if __name__ == '__main__':
        cherrypy.engine.start()
        cherrypy.engine.block()
    

    Very easy huh? Running this application directly on python will start a webserver. Configuring mod_wsgi to it will make it run inside apache.

提交回复
热议问题