1 Star 0 Fork 46

jamsf93/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()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/jamsf93/qytang_Python.git
git@gitee.com:jamsf93/qytang_Python.git
jamsf93
qytang_Python
qytang_Python
master

搜索帮助