在服务器端生成数据并将其发送到客户端?

时间:2013-12-07 00:43:23

标签: python html

你如何编写一个网页,在服务器上请求(执行)一个python脚本,然后从该脚本获取输出并将其发送回浏览器?

我目前正在参加网络编程课程,并且可能花费更多时间查找文档并提出问题而不是编写代码!谢谢你的帮助!

2 个答案:

答案 0 :(得分:0)

python -m SimpleHTTPServer [port]

答案 1 :(得分:0)

您有多个选项,但大多数选项都涉及Web服务器网关接口WSGI。寻找支持WSGI的Web服务器(Apache,Cherokee等)并使用类似这样的内容Hello World

def application(environ, start_response):
  start_response('200 OK', [('Content-Type', 'text/plain')])
  yield 'Hello World\n'