0

I have an index.py file which has to call another file which has python code whose RESULT should be displayed on the browser.

The link which I am calling is: "localhost/python/index.py?v=check" where index is the file containing the following code:

#!F:/Python/python.exe
import cgi, cgitb, os
print ("Content-Type: text/html; charset=utf-8")
print("")
cgitb.enable()
form = cgi.FieldStorage()
fileitem = form["v"]

If I am using :

print(fileitem)

then the output is displayed as check which is the value of variable v. I want the output to be the output of a file called check.py saved in the same directory as index.py

This is the code of check.py:

print("Just a check")

It has just a single line to print "Just a check"

I expect the output to be : Just a check. Is there any way to achieve this?

Adwait_07
  • 1
  • 1
  • The other script is not a cgi script, right? Just some "normal" Python function that prints to the console? – Joe Aug 08 '19 at 12:17
  • https://stackoverflow.com/questions/5136611/capture-stdout-from-a-script-in-python – Joe Aug 08 '19 at 12:17
  • https://stackoverflow.com/questions/22822267/python-capture-print-output-of-another-module/22823751 – Joe Aug 08 '19 at 12:17
  • https://code-maven.com/python-capture-stdout-stderr-exit – Joe Aug 08 '19 at 12:18

0 Answers0