简体   繁体   中英

How to serve html files from XAMPP apache server in windows

I have an html file which calls a python script to display some data from the form action tag. I want to run them through XAMPP on windows. I put my files in the cgi-bin folder after creating a subfolder named CGIPython . If I call the html file as

http://localhost:82/cgi-bin/CGIPython/Test.html

I get "The website cannot display the page" error. Even if I try a bare minimum .html file, I get the same error. However if I call my .py page directly, it works fine. I have this line in my httpd.conf file:

AddHandler cgi-script .cgi .pl .asp .py .html

I also tried putting the html files in the htdocs folder.

Thanks

First try to use test.py in /cgi-bin/ and this script have to print all html (with http header ). You can't mix html with python code like in .php file.

As default Apache runs only scripts in /cgi-bin/ so even /cgi-bin/CGIPython may needs some modifications in congif file.

Apache runs .py , .pl using operation system (Windows) and Windows knows what to do with this - it runs python or perl . But Windows don't know what to do with .html - is it python, perl or other language ?

Better use .htaccess to convert name /test.html to /cgi-bin/test.py .

RewriteEngine On
RewriteBase /
RewriteRule ^test.html$ cgi-bin/test.py 

or for all files

RewriteRule ^(.*)\.html$ cgi-bin/$1.py 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM