ks-uppercut ks-uppercut - 1 month ago 5
HTML Question

Blank screen error on google app engine

I am trying out this idea where there is a table of 'events' on a '/search' page and when a 'GO' button of an event is pressed, it will increment the 'RSVP' count of that event, and redirect back to '/search'. However, when I clicked on the 'GO' button in my application, it leads to a blank screen with url 'localhost:8080/rsvp'.

Finding it strange and wondering which part of my code is wrong. Here are some of the relevant parts of the code that I think is causing the error.

This is the code from the python file:

class RSVPItem(webapp2.RequestHandler):
# increment RSVP count when GO button is clicked
def post(self):
itemkey = ndb.Key('Items', self.request.get('itemid'))
item = itemkey.get()
item.rsvp = item.rsvp + 1

# Handler for the Search page
class Search(webapp2.RequestHandler):
# Display search page
def get(self):
user = users.get_current_user()
if user: # signed in already
# Retrieve items
query = ndb.gql("SELECT * "
"FROM Items ")

template_values = {
'user_mail': users.get_current_user().email(),
'logout': users.create_logout_url(self.request.host_url),
'items': query,
template = jinja_environment.get_template('search.html')

app = webapp2.WSGIApplication([('/', MainPage),
('/giftbook', MainPageUser),
('/wishlist', WishList),
('/deleteitem', DeleteItem),
('/search', Search),
('/rsvp', RSVPItem),
('/display', Display),
('/displaytag', Displaytag)],

This is from the html file for 'search.html'. Only showing the part I think is relevant.

<h4> Events List </h4>
<table class="table table-bordered table-striped">
<th width="10%">Name</th>
<th width = "10%">Link</th>
<th width = "10%">Date</th>
<th width = "10%">Type</th>
<th width = "10%">RSVP</th>
<th width = "10%">Rolling?</th>
{% for item in items %}
<td>{{ item.event_name }} </td>
<td>{{ item.description }}</td>
<td>{{ item.event_link}}</td>
<td>{{ item.date.strftime('%Y-%m-%d') }}</td>
<td>{{ item.event_type}}</td>
<td>{{ item.rsvp }}
<form action="/rsvp" method="post">
<input type="hidden" name="itemid" value="{{ item.item_id }}">
<input type="submit" value="GO!">
{% endfor %}


<form action="/rsvp" method="post"> sends them to /rsvp. Do you have a url handler for /rsvp?

Make sure you cast the Key to an int:

itemkey = ndb.Key('Items', int(self.request.get('itemid')))

Instead of setting your own id item_id, just use the built-in Key:

<input type="hidden" name="itemid" value="{{ item.key.id() }}">

Check the logs to see if there are any errors.