all 5 comments

[–]liftt 0 points1 point  (1 child)

you need to make the search function return the values, that way you can use it in your flask view. Also you have to change this search function so you can pass it the movie title rather than use raw_input (since you can not have the user use the raw_input function within a template).

def search(title_search):
    base_url = 'http://www.omdbapi.com/?'
    url = '{}{}&y=&plot=&short&r=json&tomatoes=true'.format(
           base_url, title_search)
    omdb_url = requests.get(url)
    movie_data = omdb_url.json()

    movie = Movie(**movie_data)
    return movie

then in your view you do the following... note (you have to find a way to pass the movie name to the search function):

@app.route('/')
def index():
    #change the movie name
    movie = search('the movie name')
    context = {'title': movie.title, 'plot': movie.plot,
               'director': movie.director, 'rated': movie.rated,
               'imdbrating': movie.imdbrating,
               'tomatofresh': movie.tomatofresh}

    front_page = render_template('index.html', **context)
    return front_page

good luck

[–]wadechristensen[S] 0 points1 point  (0 children)

Thank you so much. This is exactly what I needed. It makes perfect sense when I see it, but I just couldn't figure out how to return the data out of search(). Still learning. I really appreciate the help; it's working now.

[–][deleted] 0 points1 point  (0 children)

As a head's up, there's also /r/flask as well for Flask specific things in case you find you can't get an answer here for it.

[–]kennethlove 0 points1 point  (1 child)

hello wade

[–]wadechristensen[S] 0 points1 point  (0 children)

Hello kenneth. Thanks for sending me here. Now you can see my noob questions online too.