Python Forum
How to run a python file from html hyperlinks - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to run a python file from html hyperlinks (/thread-11348.html)



How to run a python file from html hyperlinks - dhinahar - Jul-04-2018

I connected the local host and when I click the link (timing data) from my browser i get plain python code displayed in my page.
Need to know how CGI is running python file.

code:
<p>
For now, all that you'll find here is my athlete's <a href="/webapp/cgi-bin/generate_list.py">timing data</a>. Enjoy!
</p>

Output:
import cgi
import athletemodel
import yate
import glob

data_files = glob.glob("data/*.txt")
athletes = athletemodel.put_to_store(data_files)

print(yate.start_response())
print(yate.include_header("Coach Kelly's List of Athletes"))
print(yate.start_form("generate_timing_data.py"))
print(yate.para("Select an athlete from the list to work with:"))
for each_athlete in athletes:
print(yate.radio_button("which_athlete", athletes[each_athlete].name))
print(yate.end_form("Select"))
print(yate.include_footer({"Home": "/index.html"}))