我已经使用mod\uwsgi创建了一个可以在本地调用的web服务器。现在我发现我需要修改它,让它在Apache服务器上运行。我希望在不重写整个剧本的情况下做到这一点。你知道吗
from wsgiref.simple_server import make_server
class FileUploadApp(object):
firstcult = ""
def __init__(self, root):
self.root = root
def __call__(self, environ, start_response):
if environ['REQUEST_METHOD'] == 'POST':
post = cgi.FieldStorage(
fp=environ['wsgi.input'],
environ=environ,
keep_blank_values=True
)
body = u"""
<html><body>
<head><title>title</title></head>
<h3>text</h3>
<form enctype="multipart/form-data" action="http://localhost:8088" method="post">
</body></html>
"""
return self.__bodyreturn(environ, start_response,body)
def __bodyreturn(self, environ, start_response,body):
start_response(
'200 OK',
[
('Content-type', 'text/html; charset=utf8'),
('Content-Length', str(len(body))),
]
)
return [body.encode('utf8')]
def main():
PORT = 8080
print "port:", PORT
ROOT = "/home/user/"
httpd = make_server('', PORT, FileUploadApp(ROOT))
print "Serving HTTP on port %s..."%(PORT)
httpd.serve_forever() # Respond to requests until process is killed
if __name__ == "__main__":
main()
我希望找到一种方法,使它能够避免使服务器,并使它能够运行我的脚本的多个实例。你知道吗
文档位于:
解释modèwsgi期望得到什么。你知道吗
如果你也读到:
您将了解构建WSGI应用程序入口点的各种方法。你知道吗
因此,您应该确定FileUploadApp符合所描述的定义WSGI应用程序的方法之一,因此您只需要满足mod\u WSGI对WSGI应用程序对象作为“application”访问的要求。你知道吗
相关问题 更多 >
编程相关推荐