標籤:apach 檔案 return ret text mod ide url not
1、安裝Python和Apache。
2、安裝mod_wsgi後獲得wsgi.so,並將wsgi.so放到Apache的modules檔案夾下。
3、安裝webpy。
4、開啟httpd.conf(在Apache的conf檔案夾下)
在檔案的最後加上:
LoadModule wsgi_module /modules/mod_wsgi.so
WSGIScriptAlias /webapp "D:/develop/webapp/index.py/" Alias /webapp/static "D:/develop/webapp/static/"AddType text/html .py <Directory "D:/develop/webapp/"> AllowOverride all Options Indexes FollowSymLinks ExecCGI Order allow,deny SetHandler wsgi-script Allow from all</Directory>
訪問localhost/webapp,就可以訪問D:/develop/webapp/index.py
index.py:
import web urls = ( ‘/(.*)‘, ‘hello‘)app = web.application(urls, globals())class hello: def GET(self, name): if not name: name = ‘World‘ return ‘Hello, ‘ + name + ‘!‘if __name__ == "__main__": app.run()
若不可以訪問可以嘗試開啟防火牆:
控制台-》系統安全-》允許程式通過Windows防火牆-》允許運行另一程式
添加Apache的bin檔案夾httpd.exe,並把後面的兩個勾打上。
Windows環境下使用Apache+mod