A
A
Andrey Godunko2021-11-09 10:01:38
Python
Andrey Godunko, 2021-11-09 10:01:38

When running a .py file via CGI, does it knock out all the code in the file?

Everything was done here . But I'm getting all the code. I ran the file through the terminal, indicated the full path to python.exe. But all the same in the browser knocks out

#!C:\Users\Andrey\AppData\Local\Programs\Python\Python310\python.exe

print("Content-type: text/html")
print()
print("<h1>Hello world!</h1>")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sand, 2021-11-09
@Noy-name-boy

According to the documentation :

The do_GET() and do_HEAD() functions are modified to run CGI scripts and serve the output, instead of serving files, if the request leads to somewhere below the cgi_directories path.

That is, scripts are processed only in certain directories, by default these are directories:

cgi_directories
This defaults to ['/cgi-bin', '/htbin'] and describes directories to treat as containing CGI scripts.

Scripts are not executed in other folders

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question