mirror of
https://github.com/searxng/searxng.git
synced 2025-07-14 00:39:18 +02:00
[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.
This commit is contained in:
parent
45f58a4a2a
commit
8d71420b45
17 changed files with 70 additions and 42 deletions
|
@ -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.
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue