在我将 mod_python 用于 python 网站之前。不幸的是 mod_python 不再是最新的,所以我寻找另一个框架并找到了 mod_wsgi。
在 mod_python 中,可以有索引方法和其他方法。我想要不止一页被调用。像这样的东西:
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
def test(environ, start_response):
status = '200 OK'
output = 'Hello test!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
mod_wsgi 有可能吗?
解决方案:Flask 框架可以满足我的需要
#!/usr/bin/python
from flask import Flask
from flask import request
app = Flask(__name__)
app.debug = True
@app.route("/")
def index():
return "Hello index"
@app.route("/about")#, methods=['POST', 'GET'])
def about():
content = "Hello about!!"
return content
if __name__ == "__main__":
app.run()