Apache 与 CGI

本文章的初衷就是在安装Apache后能够使用直接通过cgi使用python脚本显示网页信息

1、安装apache

参考:https://jingyan.baidu.com/article/29697b912f6539ab20de3cf8.html

2、更改httpd.conf

 参考:http://www.jb51.net/article/18993.htm

    ScriptAlias "/cgi-bin/" "E:/Apache24/cgi-bin/"
# "${SRVROOT}/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
<Directory "E:/Apache24/cgi-bin/">
    AllowOverride None
AddHandler cgi-script .pl .cgi .py
    Options All
Order allow,deny
Allow from all
</Directory>

LoadModule access_compat_module modules/mod_access_compat.so(Order 不能用时把这条打卡)

 

3、写个python脚本

#!E:\Program Files\venv\Scripts\python.exe
# encoding:gb2312
#  import cgi, cgitb
if __name__ == '__main__':
    print 'Content-type: text/html\n\n'
    print("<html>")
    print("<head><title>Hello,python</title></head>")
    a = "100";
    print("<body><h1>hello, i am ")
    print(a)
    print("</h1></body>")
    print("</html>")

 

4、运行http://127.0.0.1:8088/cgi-bin/脚本名

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值