Beispiel #1
0
def ingrd():
    """ Search an Ingredient and show results"""
    form = SearchForm(request.form)
    results = None
    if request.method == "POST":
        if form.validate_on_submit():
            ingredient = form.name.data
            results = like_ingredient_name(ingredient)
    return render_template('search/results.html',
                           var={
                               'form': form,
                               'results': results
                           })
Beispiel #2
0
def search():
    form = SearchForm()
    if form.validate_on_submit():
        name = sp.search_artist(form.artist_name.data)['name']
        genres = sp.search_artist(form.artist_name.data)['genres']
        popularity = sp.search_artist(form.artist_name.data)['popularity']
        followers = sp.search_artist(form.artist_name.data)['followers']
        fav_art = FavArtist(name=name,
                            genres=str(genres),
                            followers=followers,
                            popularity=popularity,
                            artist=current_user)
        db.session.add(fav_art)
        db.session.commit()
        #db.drop_all()
        flash('added artist info', 'success')
        return redirect(
            url_for('search.searchresult',
                    name=name,
                    genres=genres,
                    popularity=popularity,
                    followers=followers))
    return render_template('search.html', form=form)
Beispiel #3
0
 def inject_search_form():
     # inject search form to all templates
     return dict(search_form=SearchForm())
Beispiel #4
0
def before_request():
    if current_user.is_authenticated:
        current_user.last_seen = datetime.utcnow()
        db.session.commit()
    g.search_form = SearchForm()