简体   繁体   中英

Having trouble executing a python script from the web browser

I'm new to HTML and looking to integrate a python script which runs after i retrieve values from a HTML page.

I'm trying to run a sample script which takes two values (name and number) and returns a list of unique codes.

This is my python script (forms.cgi).

#!C:\Python34\Python.exe

import CampaignID, cgi
print ("Content-Type: text/html\n\n")

form = cgi.FieldStorage()

name = form.getvalue('Name')
number = form.getvalue('Number')

codes = CampaignID.CodeGen(name,number)

print(codes)

This is my below HTML script

<html>
<head>
<title>Campaign generation</title>
</head>

    <body>
    <form name = 'Campaign' action = 'forms.cgi' method = 'get'>
    <fieldset>
    <legend> Enter your restaurant Name </legend>
    <label>Name <input type = 'text' name ='Name' size = '30'></label>
    <br/>
    <legend> No. of Coupons </legend>
    <label>Number <input type = 'text' name ='Number' size = '4'></label>
    <br/>
    <hr/>
        <input type = 'submit' value = 'submit review'/>

    </fieldset>

    </form>

After filling in the values , i am getting the python file source code on the page. I'm running apache (XAMPP)

Please let me know where im going wrong.

KJ

Your action attribute is pointing to a local file on disk. It needs to be pointing to a URL served by Apache.

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