Added tbm (images/news/etc) handling, updated front page and search controls

pull/9/head
Ben Busby 4 years ago
parent 6e7eef165e
commit 1e1bb4a55a

@ -17,9 +17,13 @@ def search():
if q is None or len(q) <= 0:
return render_template('error.html')
tbm = ''
if 'tbm' in request.args:
tbm = '&tbm=' + request.args.get('tbm')
b_obj = BytesIO()
crl = pycurl.Curl()
crl.setopt(crl.URL, 'https://www.google.com/search?q=' + url_parse(q))
crl.setopt(crl.URL, 'https://www.google.com/search?q=' + url_parse(q) + tbm)
crl.setopt(crl.USERAGENT, 'Brozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 LizzieMcGuirefox/59.0')
crl.setopt(crl.WRITEDATA, b_obj)
crl.perform()

@ -2,6 +2,10 @@ document.addEventListener("DOMContentLoaded", function() {
const searchBar = document.getElementById("search-bar");
const searchBtn = document.getElementById("search-submit");
// Automatically focus on search field
searchBar.focus();
searchBar.select();
searchBar.addEventListener("keyup", function(event) {
if (event.keyCode === 13) {
event.preventDefault();

@ -1,5 +1,9 @@
<script src="/static/js/controller.js"></script>
<link rel="stylesheet" href="/static/css/main.css">
<label for="search-bar">Search: </label>
<input type="text" id="search-bar" name="search-bar"/>
<button id="search-submit" type="submit">Go</button>
<div>
<h1>No-AMP Search</h1>
<input type="text" id="search-bar" name="search-bar"/>
<button id="search-submit" type="submit">Go</button>
</div>

@ -1,3 +1 @@
<h1>Search</h1>
{{ response|safe }}

Loading…
Cancel
Save