Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completed Mini Project Week 2 #7

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
todo.txt
31 changes: 31 additions & 0 deletions movies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,37 @@
end

get '/' do
erb :search
end

get '/results' do
search = params[:movie].gsub(" ", "+")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so what are you trying to achieve with this line. Recall Stuart's note about sending params in a url, and url formatting, which was to avoid these issues by letting Typhoeus handle params

results= Typhoeus.get("www.omdbapi.com/?s=#{search}")
omdb_data = JSON.parse(results.body)

movies=omdb_data["Search"]
if movies
@movies_with_posters = movies.map do |movie|
movie_with_poster = Typhoeus.get("http://www.omdbapi.com/?i=#{movie['imdbID']}")
JSON.parse(movie_with_poster.body)
end
end

erb :index
end

get '/info/:imdbID' do
search = params[:imbdID]
results = Typhoeus.get("http://www.omdbapi.com/?i=#{params[:imdbID]}")
omdb_data = JSON.parse(results.body)

@poster=omdb_data["Poster"]
@rating=omdb_data["Rated"]
@release=omdb_data["Released"]
@runtime=omdb_data["Runtime"]
@genre=omdb_data["Genre"]
@director=omdb_data["Director"]
@actors=omdb_data["Actors"]
@plot=omdb_data["Plot"]
erb :show
end
Binary file added public/.DS_Store
Binary file not shown.
Binary file added public/curtains.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/fonts/glyphicons-halflings-regular.eot
Binary file not shown.
229 changes: 229 additions & 0 deletions public/fonts/glyphicons-halflings-regular.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/fonts/glyphicons-halflings-regular.ttf
Binary file not shown.
Binary file added public/fonts/glyphicons-halflings-regular.woff
Binary file not shown.
Loading