wampservice 支持Python CGI的配置

1.找到httpd.conf文件(D:\wamp64\bin\apache\apache2.4.23\conf\httpd.conf)

2.将 LoadModule cgi_module modules/mod_cgi.so 开启

3.<Directory "${INSTALL_DIR}/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
    Options Indexes FollowSymLinks ExecCGI(加入这条)
</Directory>

4.在<IfModule mime_module>中加入 AddHandler cgi-script .cgi .py

5.

编写的Python文件:(注意前三行,否则Internal Server Error

  1. #!D:\Python27\python.exe  //这条是重点
  2. print "Content-type:text/html"
  3. print
  4. print "hello world"


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python CGI是一种通用网关接口,用于在Web服务器上运行外部程序(通常是脚本程序)。CGI程序可以在Web服务器上生成动态内容,例如网页表单的处理、数据库查询和图像生成。在Python中,CGI编程可以使用内置的CGI模块来实现。这个模块提供了一些函数,可以方便地处理CGI请求和响应。使用CGI模块,可以将Python程序作为CGI脚本在Web服务器上运行,并且可以与Web服务器进行交互,获取HTTP请求参数、设置HTTP响应头部和发送HTTP响应内容等。要编写Python CGI程序,需要在Web服务器上安装Python解释器,并将CGI脚本放置在Web服务器的CGI目录中。在Python中,可以导入cgi模块和CgiHTTPServer模块来实现CGI编程。另外,可以使用命令行启动cgi服务来运行CGI脚本。123 #### 引用[.reference_title] - *1* [一文理解 Python CGI](https://blog.csdn.net/mynewdays/article/details/125651783)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] - *2* [Python CGI编程](https://blog.csdn.net/smarten57/article/details/130773033)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] - *3* [35.从入门到精通:Python CGI编程 什么是CGI 网页浏览 CGI架构图 Web服务器支持配置 第一个CGI程序 HTTP...](https://blog.csdn.net/weixin_63740705/article/details/131381933)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值