I need to send some HTML form data to a python script for formatting but 
don't know how to do this. The user enters the data into a HTML form. The 
data is sent to a script where it is cleaned up and tokenized. The revised 
data is sent to another python function where it is to be used. How do I go 
about this? Does every python function go into the default.py controller or 
should I create a new .py file to process the form data? I have an example 
here. This takes the search term as input by the user and sends it to the 
results page. How would I send it to a python script before sending it to 
the results page? I'm really confused by this!

index.html:

<div id="MainArea">
  <p align="center">MY SEARCH ENGINE</p>
  <form name="form1" method="get" action="results.html">
    <label for="SearchBar"></label>
    <div align="center">
      <input name="query" type="text" id="SearchBar" value="" size = "100px"
><br />
      <input name="submit" type="submit" value="Search">
    </div>
  </form>
  <p align="center">&nbsp;</p>
  
</div>

results.html

{{extend 'layout.html'}}
<h1>This is the default/results.html template</h1>
{{=BEAUTIFY(response._vars)}}


<div>{{=results}}</div>

default.py:

import urllib2


def index():
    return dict()
 
def results():
    address = "http://www.blekko.com/?q=%(query)s+/json&auth=<mykey>" % dict
(query=request.vars.query)
    response = urllib2.urlopen(address)
    html=response.read()
    return html



Reply via email to