python - 如何在apache中指定python文件的路径
问题描述
我现在正在 windows10 上构建服务器。
使用的服务器是apache,语言是python。
修改 apache 的 httpd.conf 以使用 python 文件。
我在 htdocs 下创建了一个名为 helloworld.py 的 python 文件。
该文件的内容如下。
#!C:\Users\z05974ac\AppData\Local\Microsoft\WindowsApps\python.exe
# coding:utf-8
print ("Content-Type: text/html\n");
print ("Hello World!");
第一行是输入 where python 的结果。
但是,显示了以下错误消息。
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at admin@example.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
我认为设置路径的方式存在问题。
但我不明白原因。
我会很感激你的教导。
谢谢你。
解决方案
我对 Apache 了解不多,但是否因为您在行尾有一个分号?Python 只需要一个新行来分隔代码,所有 C 语言都需要一个分号在它们的末尾。只需将这些行重写为:
print ("Content-Type: text/html\n")
print ("Hello World!")
推荐阅读
- c# - 从头开始用于 WinForm 的 C# 功能区控件
- linux - sed 命令删除该行中的字符串及其后面的所有内容
- docker - Docker撰写不安装卷?
- sql-server - 将 SELECT TOP 与 OPTION (FAST N) 结合使用是否会改变执行计划?
- typescript - 如何使用打字稿为猫鼬创建自定义模式类型
- android - 如何动态替换Android中的按钮?
- ms-access - 访问 ComboBox 绑定和选定值
- html - 如何更改每个动态创建的 FlexBox 的背景颜色?
- android - 从 RecyclerViewAdapter 类创建新片段
- asp.net-mvc - 如何禁用@html.Editor() 使其只读