概要
<script type="text/javascript">loadTOCNode(1, 'summary');</script>
Python 是一种解释脚本语言概念中类似于 Microsoft Visual Basic Scripting Edition (VBScript)、 MicrosoftJScript、 Perl, 或其他脚本语言。 对于 Active Server Pages (ASP) 以及简单通用网关接口 (CGI) 脚本而 Internet Information Server (IIS) 使用 WindowsScriptingHost 针对其 VBScript 和 JScript 需要, IIS 可以使用其他脚本解释程序。 本文介绍如何使用 Python 作为脚本语言是选择用于 CGI 和 ASP。
更多信息
<script type="text/javascript">loadTOCNode(1, 'moreinformation');</script> 您可以选择任何 Python 解释作为脚本引擎用于处理 Python 脚本。 本文中示例使用 ActiveState 的 ActivePython 2.0。以下步骤显示如何设置安装 Python 解释为用于与 IIS 和 ASP 脚本引擎。
1. | 确保 Web 站点包含 Python 脚本具有应用程序设置。 要这样做, 执行以下步骤:
| ||||||||||||||||
2. | 验证已设置对于 .py 文件应用程序映射。 要这样做, 执行以下步骤:
| ||||||||||||||||
3. | 确 保文件和目录权限正确设置计算机的访问控制列表 (ACL) 中。 必须用于匿名访问, IUSR _ [ computername ] 和 IWAM _ computername ] [ 用户帐户具有至少 " 读取 " 权限 (RX)。 当使用其他类型的密码验证, 权限要求可能有所不同。 |
文本中创建文件编辑器 (如 Microsoft 记事本, 并包括下面的代码行。 以脚本文件夹作为保存文件 Test.py.
print 'Status: 200 OK'
print 'Content-type: text/html'
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>'
浏览 Web 站点上 " Test.py ":
http:// < computer_name > /scripts/test.py
或者, 可以使用 Python 解释作为您脚本解释您 ASP 页中 有注册, Python 脚本引擎后通过使用记事本创建文件并包括下面的代码行。 以脚本文件夹作为保存文件
Python.asp .
<%@LANGUAGE=Python%>
<HTML>
<head></head>
<body>
<h1>Python Test</h1>
<%
#do some python stuff here
Response.Write('Python Test<br>')
Response.write('<h3>Smaller heading</hr>')
%>
</body>
</html>
浏览 Web 站点上 " Python.asp ":
http:// < computer_name > /scripts/python.asp