16 Star 44 Fork 45

现任明教教主-乾颐堂 / qytang_Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
2016.02.14 cgi language 打印小实验 PY (优化设计) 941 Bytes
一键复制 编辑 原始数据 按行查看 历史
现任明教教主-乾颐堂 提交于 2016-02-14 11:05 . new file
#!/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()
Python
1
https://gitee.com/qytang/qytang_Python.git
git@gitee.com:qytang/qytang_Python.git
qytang
qytang_Python
qytang_Python
master

搜索帮助