Exemple #1
0
 def get(self):
     greetings = Greetings.query().order(-Greetings.timestamp).fetch()
     greetings_dict = {'greetings': greetings}
     template_dir = os.path.join(os.path.dirname(__file__), 'templates')
     jinja_environment = jinja2.Environment(
         loader=jinja2.FileSystemLoader(template_dir))
     template = jinja_environment.get_template('home.html')
     rendered_template = template.render(greetings_dict)
     self.response.write(rendered_template)
Exemple #2
0
    def post(self):
        logging.debug(self.request)
        user_name = self.request.get("user_name")
        message = self.request.get("message")

        logging.debug("Message: \n\tUser Name: {}\n\tMessage: {}\n".format(
            user_name, message))
        Greetings(name=user_name, message=message).put()
        logging.debug("POST Successful")
    def get(self):
        results = Greetings.query().order(-Greetings.timestamp).fetch()

        results_dict = {"greetings": results}

        template_dir = os.path.join(os.path.dirname(__file__), "templates")

        jinja_env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir))

        template = jinja_env.get_template("home.html")
        rendered_template = template.render(results_dict)

        self.response.write(rendered_template)
Exemple #4
0
    def get(self):

        # Get all past Greetings from the datastore
        results = Greetings.query().fetch(
        )  # Can put an integer argument in fetch() to limit to N number of results
        results_dict = {'greetings': results}

        # HTML Template
        template_dir = os.path.join(os.path.dirname(__file__), 'templates')

        jinja_environment = jinja2.Environment(
            loader=jinja2.FileSystemLoader(template_dir))

        template = jinja_environment.get_template('home.html')
        rendered_template = template.render(results_dict)

        self.response.write(rendered_template)
    def get(self):

        # Get all past Greetings from the datastore
        results = Greetings.query().fetch()  # Can put an integer argument in fetch() to limit to N number of results
        results_dict = {'greetings': results}


        # HTML Template
        template_dir = os.path.join(os.path.dirname(__file__), 'templates')

        jinja_environment = jinja2.Environment(
            loader=jinja2.FileSystemLoader(template_dir)
        )

        template = jinja_environment.get_template('home.html')
        rendered_template = template.render(results_dict)

        self.response.write(rendered_template)
Exemple #6
0
 def post(self):
     user_name = self.request.get('user_name')
     message = self.request.get('message')
     Greetings(name=user_name, message=message).put()
     self.redirect('/')
Exemple #7
0
def hello():
    return render_template("index.html", message=Greetings.get_welcome())