Hi all,
I'm trying to get to grips with web2py. I want to get the user to fill in a
search form, the term they search for is sent to my python script which
should send the query to the blekko API and output the results to them in a
new HTML page. I've implemented the following code but instead of my normal
index page appearing, I'm getting the html response directly from blekko
with '%(query)' /html appearing in it's search bar. Really need some help
with this!
HTML form on the default/index.html page
<body>
<div id="MainWrapper">
<div id="MainArea">
<p align="center">MY SEARCH ENGINE</p>
<form name="form1" method="get" action="">
<label for="SearchBar"></label>
<div align="center">
<input name="SearchBar" type="text" id="SearchBar" value="" size =
"100px"><br />
<input name="submit" type="submit" value="Search">
</div>
</form>
<p align="center"> </p>
Python code on the default.py controller
import urllib2
def index():
import urllib2
address = "http://www.blekko.com/?q='%(query)'+/html&auth=<mykey>"
query = request.vars.query
response = urllib2.urlopen(address)
html=response.read()
return html