简体   繁体   中英

How can I run an html page from python using CGI

I am on a project where I have connected python and html using CGI. I am now able to receive inputs from html and save it to MySQL database through python. My project is a ticket booking website. I now have to show the user that their tickets have been booked, and also, I will have to show them their fare. Though I can simply type the code in printing statements to print the data in html, it doesn't look good from the user side, as I can't style it. Has anyone got any solutions? Can I directly start any html page like that?

I tried to print the fare, and I was able to do it. But the page looked very boring without any styling. I want to open an html page from my python file (because I can style it)-, but I am not using any web application like Flask or Django. How can I do it?

To run your Python script as a CGI script, you can either:

  1. Name your script with a. cgi file extension (example. cgi).
  2. Configure Apache to recognize and allow the. py file extension as a CGI script.

To run your Python script as a CGI script, you can either:

Name your script with a.cgi file extension (example.cgi). Configure Apache to recognize and allow the.py file extension as a CGI script.

To run your python script as a CGI script,you can either:

  1. Name your script with a.cgi file extension (example.cgi).
  2. Configure Apache to recognize and allow the.py file extension as a CGI extension

"Run a HTML page" doen't make much sense. Sounds like your Python script is already running under CGI, and it's html output needs to include style information.

Print out the style information as well as the values into your html.
Or print out a link into the html header to include a seperate style sheet.
Or use python to load a html template from a file and make some string substitutions with your data before printing out the edited template.

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