Python cgi脚本不支持共享主机

时间:2014-06-01 21:19:14

标签: python flask cgi shared-hosting

#!/usr/bin/python

print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<head>'
print '<title>Hello Word - First CGI Program</title>'
print '</head>'
print '<body>'

from wsgiref.handlers import CGIHandler
from app import app

CGIHandler().run(app)

a=9
b=8
c=a+b
import test
d=test.addd(77,88)
print c
print d
print '<h2>Hello Word! This is my first CGI program</h2>'
print '</body>'
print '</html>'

"""The above code is in my cgi-bin folder as sumitup.py which works fine and gives the add   part of the code as result in the browser when I remove the below import part."""
from wsgiref.handlers import CGIHandler
from app import app

CGIHandler().run(app)

&#34;&#34;&#34;我创建了一个test.py并尝试调用addd方法,该方法也正常工作。     我是否需要在同一文件夹中添加wsgiref.handlers library explicity的代码。     注意: - 我正在尝试在共享主机www.techpython.com上部署flask应用程序     你可以帮我吗。谢谢。&#34;&#34;&#34;

1 个答案:

答案 0 :(得分:0)

CGIHandler为您处理CGI请求。

无需打印content-length或类似的内容。

CGIHandler之上,您可以使用类似Werkzeug(http://werkzeug.pocoo.net/)的内容。