Skip to content
This repository was archived by the owner on Dec 1, 2022. It is now read-only.
Open
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
83 changes: 70 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,84 @@
import webapp2


# html boilerplate for the top of every page
page_header = """
<!DOCTYPE html>
<html>
<head>
<title>FlickList</title>
</head>
<body>
<h1>FlickList</h1>
"""

# html boilerplate for the bottom of every page
page_footer = """
</body>
</html>
"""

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 = "<h3>Edit My Watchlist</h3>"

# TODO: randomly choose one of the movies, and return it
# a form for adding new movies
add_form = """
<form action="/add" method="post">
<label>
I want to add
<input type="text" name="new-movie"/>
to my watchlist.
</label>
<input type="submit" value="Add It"/>
</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 (<select>) instead a
# text box (<input type="text"/>)


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 = "<strong>" + new_movie + "</strong>"
sentence = new_movie_element + " has been added to your Watchlist!"

content = page_header + "<p>" + sentence + "</p>" + page_footer
self.response.write(content)

def get(self):
movie = self.getRandomMovie()

# build the response string
response = "<h1>Movie of the Day</h1>"
response += "<p>" + movie + "</p>"
# 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 "<h1>Tommorrow's Movie</h1>"

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)