From 8d71420b4511fdac63c39f33d93c7add1ea7716d Mon Sep 17 00:00:00 2001 From: Marc Abonce Seguin Date: Mon, 29 Jul 2019 21:25:05 -0700 Subject: [mod] separate index and search routes This makes it easier to separately handle search and index requests from a web server or from a reverse proxy. If a request to index contains a query, a permanent redirect HTTP response is returned. This should give some level of backwards compatibility for users that have set a searx instance in their browser's search bar. --- searx/webapp.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'searx/webapp.py') diff --git a/searx/webapp.py b/searx/webapp.py index 609669b85..46d547d52 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -531,10 +531,22 @@ def index_error(output_format, error_message): ) -@app.route('/search', methods=['GET', 'POST']) @app.route('/', methods=['GET', 'POST']) def index(): - """Render index page. + """Render index page.""" + + # redirect to search if there's a query in the request + if request.form.get('q'): + return redirect(url_for('search'), 308) + + return render( + 'index.html', + ) + + +@app.route('/search', methods=['GET', 'POST']) +def search(): + """Search query in q and return results. Supported outputs: html, json, csv, rss. """ -- cgit v1.2.3