Write CGI with Python (Lighttpd Server)
来源:互联网 发布:淘宝新开店铺没有流量 编辑:程序博客网 时间:2024/06/05 10:24
1. Add the following configurations to your lighttpd.conf:
server.modules= ( "mod_cgi" )cgi.assign= ( ".py" => "/usr/bin/python2" )2. Write a simple website as an interface to add two integers:
<html> <head> <title>Test CGI</title> </head> <body> <form action="/test.py"> <p>Add two integer, please input two integer:</p> <input name="a" size="4"/> <input name="b" size="4"/> <input type="submit" values="submit"/> </form> </body></html>3. Write the test.py to add two or more integers:
# Test python for cgiimport osimport urlparseimport cgitbimport stringcgitb.enable()# Get the query string from environment, it is set by lighttpdquery = os.getenv('QUERY_STRING')sum = 0# Print the headerprint 'Content-Type: text/html'printprint '<title>Python CGI</title>'print '<h1>Test Python for CGI</h1>'# Sum up all the valuesif query is not None: pairs = urlparse.parse_qs(query) # pairs is a dict for key, value in pairs.items(): # value is a list print '<p>key = %s, value = %s</p>' %(key, value) sum += string.atoi(value[0])# Print the resultprint '<p>Sum = %d</p>' %sum4. OK, it is very easy, have fun!
- Write CGI with Python (Lighttpd Server)
- lighttpd 服务器搭建过程记录2【with CGI】
- write excel with python xlwt
- write lighttpd mod
- Lighttpd(linux lighttpd)中CGI执行流程
- Lighttpd中CGI执行流程
- lighttpd中 CGI 执行原理图
- Lighttpd中CGI执行流程
- Lighttpd中CGI执行流程
- Lighttpd中cgi执行流程
- Lighttpd中CGI执行流程
- Read & Write Excel files with Python
- Write Excel files with Python using xlwt
- [Python 2.7] Hello World CGI HTTP Server
- Write a simple HTTP server in Python
- Lighttpd中CGI执行流程(转)
- Using shell scripts for CGI in lighttpd
- Ruby CGI lib compare with Python CGI lib: Get form value
- 最简洁的短信弹窗提醒应用
- ubuntu系统现汉字的显示
- word右键添加百度谷歌搜索,word右键添加打开某个文件夹选项
- php面向对象实例笔记
- 【Q&A】delete (free)如何知道被删除的数组的元组个数?
- Write CGI with Python (Lighttpd Server)
- Android加密算法:AES、Base64加密算法
- winform中为ComboBox控件添加“请选择”或“全部”选项
- document.getElementById/Name/TagName
- 消费者与生产者问题代码
- C语言中的堆和栈
- Netbeans 调试 glassfish
- 虚拟机的Linux通过Host-only方式上网的设置
- struts2文件下载功能实现(文件名中文转码)