Added tbm (images/news/etc) handling, updated front page and search controls
parent
6e7eef165e
commit
1e1bb4a55a
|
@ -17,9 +17,13 @@ def search():
|
||||||
if q is None or len(q) <= 0:
|
if q is None or len(q) <= 0:
|
||||||
return render_template('error.html')
|
return render_template('error.html')
|
||||||
|
|
||||||
|
tbm = ''
|
||||||
|
if 'tbm' in request.args:
|
||||||
|
tbm = '&tbm=' + request.args.get('tbm')
|
||||||
|
|
||||||
b_obj = BytesIO()
|
b_obj = BytesIO()
|
||||||
crl = pycurl.Curl()
|
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.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.setopt(crl.WRITEDATA, b_obj)
|
||||||
crl.perform()
|
crl.perform()
|
||||||
|
|
|
@ -2,6 +2,10 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||||
const searchBar = document.getElementById("search-bar");
|
const searchBar = document.getElementById("search-bar");
|
||||||
const searchBtn = document.getElementById("search-submit");
|
const searchBtn = document.getElementById("search-submit");
|
||||||
|
|
||||||
|
// Automatically focus on search field
|
||||||
|
searchBar.focus();
|
||||||
|
searchBar.select();
|
||||||
|
|
||||||
searchBar.addEventListener("keyup", function(event) {
|
searchBar.addEventListener("keyup", function(event) {
|
||||||
if (event.keyCode === 13) {
|
if (event.keyCode === 13) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
<script src="/static/js/controller.js"></script>
|
<script src="/static/js/controller.js"></script>
|
||||||
|
<link rel="stylesheet" href="/static/css/main.css">
|
||||||
|
|
||||||
<label for="search-bar">Search: </label>
|
<div>
|
||||||
<input type="text" id="search-bar" name="search-bar"/>
|
<h1>No-AMP Search</h1>
|
||||||
<button id="search-submit" type="submit">Go</button>
|
|
||||||
|
<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 }}
|
{{ response|safe }}
|
||||||
|
|
Loading…
Reference in New Issue