Python 是一种解释脚本语言,概念类似 Microsoft Visual Basic Scripting Edition (VBScript)、 MicrosoftJScript、 Perl, 或其他脚本语言。 对于 Active Server Pages (ASP) 以及简单通用网关接口 (CGI) 脚本,IIS使用 WindowsScriptingHost 解析VBScript 和 JScript , IIS 可以使用其他脚本解释程序。 本文介绍如何使用 Python 作为脚本语言是选择用于 CGI 和 ASP。

在IIS管理器“网站”节点上点击右键,选择“属性”“主目录”,点击“配置”按钮,在“映射”中点击“添加”,在对话框中将“可执行文件”设置为“<python安装目录>/python.exe %s %s”,扩展名为“.py”,动作为“全部动作”,然后点击确定。

IIS现在就能解析py了吗?编写一个test.py文件:

print
print 'Status: 200 OK'
print 'Content-type: text/html'
print

print '<HTML><HEAD><TITLE>Python Sample CGI</TITLE></HEAD>'
print '<BODY>'
print '<H1>This is a header</H1>'

print '<p>' #this is a comment
print 'See this is just like most other HTML'
print '<br>'
print '</BODY>'

如果使用IIS访问,类似http://localhost/test.py,显示内容为:

See this is just like most other HTML
 

即可!

相关文章:

  • 2021-09-03
  • 2022-12-23
  • 2021-12-03
  • 2021-08-04
  • 2021-06-04
  • 2021-07-05
  • 2021-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2021-11-23
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2021-11-24
相关资源
相似解决方案