Skip to Content
Flask Framework Cookbook - Second Edition
book

Flask Framework Cookbook - Second Edition

by Shalabh Aggarwal
July 2019
Beginner to intermediate
302 pages
9h 38m
English
Packt Publishing
Content preview from Flask Framework Cookbook - Second Edition

How to do it...

The following is a method that searches in our catalog application for name, price, company, and category. We can search for any one criterion, or multiple criteria (except for the last search on category, which can only be searched alone). Notice that we have different expressions for different values. For a float value in price, we can search for equality, and in the case of a string, we can search using like. Also, carefully note how join is implemented in the case of category. Place this method in the views file, that is, flask_catalog_template/my_app/catalog/views.py:

from sqlalchemy.orm.util import join @catalog.route('/product-search') @catalog.route('/product-search/<int:page>') def product_search(page=1): name = request.args.get('name') ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Writing a Web Application with Flask

Writing a Web Application with Flask

Doug Farrell
Mastering Flask

Mastering Flask

Jack Stouffer

Publisher Resources

ISBN: 9781789951295Supplemental Content