Add iframe-able search page for insertion into other sites

Introduces a new html template, search.html, which provides a very basic
form for submitting search queries.

Closes #319
main
Ben Busby 2021-05-21 10:35:46 -04:00
parent 3f1096b05d
commit d5eebe9fe5
No known key found for this signature in database
GPG Key ID: 3B08611DF6E62ED2
2 changed files with 21 additions and 0 deletions

View File

@ -159,6 +159,14 @@ def opensearch():
), 200, {'Content-Disposition': 'attachment; filename="opensearch.xml"'} ), 200, {'Content-Disposition': 'attachment; filename="opensearch.xml"'}
@app.route('/search.html', methods=['GET'])
def search_html():
search_url = g.app_location
if search_url.endswith('/'):
search_url = search_url[:-1]
return render_template('search.html', url=search_url)
@app.route('/autocomplete', methods=['GET', 'POST']) @app.route('/autocomplete', methods=['GET', 'POST'])
def autocomplete(): def autocomplete():
q = g.request_params.get('q') q = g.request_params.get('q')

13
app/templates/search.html Normal file
View File

@ -0,0 +1,13 @@
<form id="search-form" action="{{ url }}/search" method="post">
<input
type="text"
name="q"
style="width: 90%;"
autofocus="autofocus"
autocapitalize="none"
spellcheck="false"
autocorrect="off"
placeholder="Whoogle Search"
autocomplete="off">
<input type="submit" style="width: 9%" id="search-submit" value="Search">
</form>