Skip to content

Commit

Permalink
Merge pull request #9 from LyubomirT/master
Browse files Browse the repository at this point in the history
Search for tasks in `search.html`
  • Loading branch information
Ctoic authored Jan 9, 2024
2 parents a4384a5 + 5aa4b4a commit 63c9eb8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def delete(id):
db.session.commit()
return redirect(url_for('Home'))

# Inside the `search` route
@app.route('/search', methods=['GET'])
def search():
search_query = request.args.get('search')
Expand All @@ -66,6 +67,7 @@ def search():
return render_template('search.html', todos=todos)
return redirect(url_for('Home'))


@app.route('/about')
def about():
return render_template('about.html')
Expand Down
9 changes: 5 additions & 4 deletions templates/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@
<input
class="form-control mr-sm-2"
type="text"
name="query"
name="search"
placeholder="Search"
aria-label="Search"
/>
<button class="btn btn-outline-dark my-2 my-sm-0" type="submit">
Search
Search
</button>
</form>
</form>

</div>
</nav>
</nav>
12 changes: 6 additions & 6 deletions templates/search.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% extends "base.html" %}
{% block body %}
<h2>Search Results</h2>
<ul>
{% for todo in todos %}
<li>{{ todo.title }} - {{ todo.desc }}</li>
{% endfor %}
</ul>
<h2>Search Results</h2>
<ul>
{% for todo in todos %}
<li>{{ todo.title }} - {{ todo.desc }}</li>
{% endfor %}
</ul>
{% endblock body %}

0 comments on commit 63c9eb8

Please sign in to comment.