代码拉取完成,页面将自动刷新
#!/usr/bin/python3.4
# -*- coding=utf-8 -*-
import cgi, sys
from formMockup import FieldMockup
from lang2com import hellos, inputkey
debugme = False
dhrhtml = """Content-type: text/html\n
<TITLE>Languages</TITLE>
<H1>Syntax</H1><HR>"""
langhtml = """
<H3>%s</H3><P><PRE>
%s
</PRE></P><BR>"""
def showHello(form):
choice = form[inputkey].value
try:
print(langhtml % (cgi.escape(choice),
cgi.escape(hellos[choice])))
except KeyError:
print(langhtml % (cgi.escape(choice),
"Sorry -- I don'not Know that language"))
def main():
if debugme:
form = {inputkey: FieldMockup(sys.argv[1])}
else:
form = cgi.FieldStorage()
print(dhrhtml)
if not inputkey in form or form[inputkey].value == 'ALL':
for lang in hellos.keys():
mock = {inputkey: FieldMockup(lang)}
showHello(mock)
else:
showHello(form)
print("<HR>")
if __name__ == '__main__':
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。