.jsp file not working for Google App Engine guestbook tutorial
By : challenking
Date : March 29 2020, 07:55 AM
wish of those help In the end I seem to have wasted my bounty as I found the solution (with a little help) myself. The problem arose because I was unfamiliar with Eclipse. When I found the more verbose error message Your project must be configured to use a JDK in order to use JSPs guestbook.jsp. It was located in a tab called 'Markers' in pane found at the bottom of the Eclipse window. It seems that Eclipse wasn't aware that I had installed the JDK.
|
How to add date and time under each post in guestbook in google app engine
By : Artur Majtczak
Date : March 29 2020, 07:55 AM
it fixes the issue Use the strftime() method on the datetime instance greeting.date with something like this: code :
for greeting in greetings:
self.response.out.write(greeting.date.strftime('<b>posted:%Y-%m-%d %H:%M:%S</b><br>'))
import cgi
import datetime
import wsgiref.handlers
from google.appengine.ext import db
from google.appengine.api import users
from google.appengine.ext import webapp
class Greeting(db.Model):
author = db.UserProperty()
content = db.StringProperty(multiline=True)
date = db.DateTimeProperty(auto_now_add=True)
class MainPage(webapp.RequestHandler):
def get(self):
self.response.out.write('<html><body>')
greetings = db.GqlQuery("SELECT * FROM Greeting ORDER BY date DESC LIMIT 10")
for greeting in greetings:
self.response.out.write(greeting.date.strftime('<b>posted: %Y-%m-%d %H:%M:%S</b><br>'))
if greeting.author:
self.response.out.write('<b>%s</b> wrote:' % greeting.author.nickname())
else:
self.response.out.write('An anonymous person wrote:')
self.response.out.write('<blockquote>%s</blockquote>' %
cgi.escape(greeting.content))
# Write the submission form and the footer of the page
self.response.out.write("""
<form action="/sign" method="post">
<div><textarea name="content" rows="3" cols="60"></textarea></div>
<div><input type="submit" value="Sign Guestbook"></div>
</form>
</body>
</html>""")
class Guestbook(webapp.RequestHandler):
def post(self):
greeting = Greeting()
if users.get_current_user():
greeting.author = users.get_current_user()
greeting.content = self.request.get('content')
greeting.put()
self.redirect('/')
application = webapp.WSGIApplication([
('/', MainPage),
('/sign', Guestbook)
], debug=True)
def main():
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()
|
How can I insert a background image in google app engine using index.css for guestbook application?
By : jshell83
Date : March 29 2020, 07:55 AM
should help you out Take a look at the background-image css property. Your body rule would change to something like: code :
body {
font-family: Comic Sans, Helvetica, sans-serif;
background-image: url('images/my_background.jpg');
}
|
Google App Engine Java with mvn devserver failed: missing "guestbook/target/guestbook-1.0-SNAPSHOT"
By : 高朝进
Date : March 29 2020, 07:55 AM
it helps some times You have to run mvn appengine:devserver in the guestbook-ear folder. I was running it on the top level.
|
How to make a 'permalink' detail page displaying two images in Google App Engine webapp2 guestbook tutorial
By : piggywiggy
Date : March 29 2020, 07:55 AM
hop of those help? I'll start with B: The error indicates that the greeting value is None, leading to an exception when jinja2 attempts to expand greeting.key in {{ greeting.key.urlsafe() }} during template rendering. code :
...
greeting = Greeting.get_by_id(args[0])
if not greeting or not isinstance(greeting.key, ndb.Key):
# can't render that template, invalid greeting.key.urlsafe()
webapp2.abort(500)
return
template_values = {
'greeting': greeting,
}
template = JINJA_ENVIRONMENT.get_template('detail.html')
self.response.write(template.render(template_values))
...
{% if greeting and greeting.key %}<img src="/img?avatar_img_id={{ greeting.key.urlsafe() }}">{% endif %}
greeting = Greeting(parent=guestbook_key(guestbook_name))
greeting = Greeting.get_by_id(args[0],
parent=guestbook_key(guestbook_name))
/guestbook/<guestbook_name>/greeting/<numeric-id>.
|