diff --git a/main.py b/main.py index 99fa49b..3bb4c71 100644 --- a/main.py +++ b/main.py @@ -1,27 +1,84 @@ import webapp2 + +# html boilerplate for the top of every page +page_header = """ + + + + FlickList + + +

FlickList

+""" + +# html boilerplate for the bottom of every page +page_footer = """ + + +""" + class Index(webapp2.RequestHandler): + """ Handles requests coming in to '/' (the root of our site) + e.g. www.flicklist.com/ + """ - def getRandomMovie(self): + def get(self): - # TODO: make a list with at least 5 movie titles + edit_header = "

Edit My Watchlist

" - # TODO: randomly choose one of the movies, and return it + # a form for adding new movies + add_form = """ +
+ + +
+ """ - return "The Big Lebowski" + # TODO 1 + # Include another form so the user can "cross off" a movie from their list. + + + # TODO 4 (Extra Credit) + # modify your form to use a dropdown () + + + content = page_header + edit_header + add_form + page_footer + self.response.write(content) + + +class AddMovie(webapp2.RequestHandler): + """ Handles requests coming in to '/add' + e.g. www.flicklist.com/add + """ + + def post(self): + # look inside the request to figure out what the user typed + new_movie = self.request.get("new-movie") + + # build response content + new_movie_element = "" + new_movie + "" + sentence = new_movie_element + " has been added to your Watchlist!" + + content = page_header + "

" + sentence + "

" + page_footer + self.response.write(content) - def get(self): - movie = self.getRandomMovie() - # build the response string - response = "

Movie of the Day

" - response += "

" + movie + "

" +# TODO 2 +# Create a new RequestHandler class called CrossOffMovie, to receive and +# handle the request from your 'cross-off' form. The user should see a message like: +# "Star Wars has been crossed off your watchlist". - # TODO: pick a different random movie, and display it under - # the heading "

Tommorrow's Movie

" - self.response.write(response) +# TODO 3 +# Include a route for your cross-off handler, by adding another tuple to the list below. app = webapp2.WSGIApplication([ - ('/', Index) + ('/', Index), + ('/add', AddMovie) ], debug=True)