|
-
-
-
-
-
-
-
-
- from flask import Blueprint, render_template, request, flash, redirect, url_for
- from .models import Resource
- from sqlalchemy import or_
- import markdown
-
- search = Blueprint('search', __name__)
-
-
- @search.route('/search', methods=['GET'])
- def basic_search():
- if request.args.get('query') is not None:
- query = request.args.get('query')
- results = Resource.query.filter(
- or_(
- Resource.name.ilike('%' + query + '%'),
- Resource.description.ilike('%' + query + '%'),
- Resource.developer.ilike('%' + query + '%'),
- Resource.longDescription.ilike('%' + query + '%'),
- Resource.experimental.ilike('%' + query + '%'),
- Resource.considerations.ilike('%' + query + '%'),
- Resource.references.ilike('%' + query + '%'),
- Resource.author.ilike('%' + query + '%'),
- Resource.isbn.ilike('%' + query + '%'),
- Resource.typology.ilike('%' + query + '%'),
- )).all()
-
- for result in results:
- result.description = markdown.markdown(result.description)
- return render_template('search.html', results=results)
- else:
- return redirect(url_for('main.index'))
|