Python,Crusher,XAMPP,CGI
来源:互联网 发布:时光倒流软件 编辑:程序博客网 时间:2024/05/21 03:29
The way to use CGI in Python and in the XAMPP under Win-7:
1.install Python and XAMPP first and add the env var of Python:
2.install XAMPP:
3.Add the mysql env var for the system:
E:\xampp\mysql\bin
4.chang the password for the root user:
5. add the following lines to the file E:\xampp\apache\conf\httpd.conf :
AddHandler cgi-script .cgi .pl .asp .py
AddType text/html .shtml .py
Options Indexes FollowSymLinks Includes ExecCGI
6.new a file named hello.py:
you should notice the right path of the python.exe or it will be error by Apache
#!C:\Python27\python.exeprint "Content-Type: text/html\n"print """<html><title>hello Crusher</title><body><h1>Hello Python CGI <a href="http://www.conecrusherplant.net">Crusher</a></h1></body></html>"""
test:
7. try the CGI with the Mysql and the data:
sql:
create database books;use books;create table book (id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,name VARCHAR(255));insert into book (name) values ("Django book");insert into book (name) values ("Python Book");
8.the python code:
#!C:\Python27\python.exeimport MySQLdbprint "Content-Type: text/html\n"print "<html><head><title>Books</title></head>"print "<body>"print "<h1>Books</h1>"print "<ul>"connection = MySQLdb.connect(user='root', passwd='zoosuck', db='books')cursor = connection.cursor()cursor.execute("SELECT name from book;")for row in cursor.fetchall(): print "<li>%s</li>" % row[0]print "</ul>"print "</body></html>"connection.close()
9.the data in the page:
Now, you can programming with Python and CGI!
- Python,Crusher,XAMPP,CGI
- Python "Stone Crusher For Sale From Zenith Counter" Words
- Python CGI
- Python的CGI配置
- python for cgi
- Perl & Python编写CGI
- Python CGI Apache
- python cgi 内容记录
- apache 配置 python cgi
- Python CGI编程
- Python CGI编程
- Python网页编程(CGI)
- Python CGI编程
- Ajax,python数据库,cgi,
- Python CGI 模块剖析
- Python CGI编程
- Python CGI初体验
- Python CGI编程
- (C++实现)——组合模式(Composite Pattern)
- 图像金字塔L-K光流法模型的学习
- PXE+DHCP+Apache+Kickstart自动安装CentOS
- Jquery的右键菜单插件ContextMenu
- Java中的transient,volatile和strictfp关键字
- Python,Crusher,XAMPP,CGI
- 用jquery的ajax时遇到的中文乱码
- c++primer 学习笔记
- 绘图基础--画弧,扇形,弓形
- 如何卸载Ubuntu中多余内核
- Code Jam 2010 Round 1A Problem B
- 智能指针容器及STL容器
- Linux下编译安装mysql5.5
- 金字塔Lucas-Kanade稀疏光流