def post(self): # This grabs the post value called name that was passed. name = self.request.get('name') if name: # Here we create a new Name object in the database. # We assign the name field with the new name that was passed on in the POST. new_name = Name(name=name) # And here we save it to the database. new_name.put() # Finally, we redirect back to the original page (GET). self.redirect('/post')
def load_audio(tts, text): from model import Name existing: Name = Name.query.filter_by(text=text).first() if existing: existing.last_access = datetime.datetime.utcnow() return existing.data audio = text_to_speech(tts, text) new_row = Name(text=text, data=audio) db.session.add(new_row) db.session.commit() return audio
def get(self): # Here we call the database. We are pulling all names out. names = Name.all() template_values = {"names":names} path = os.path.join(os.path.dirname(__file__), 'templates/post.html') self.response.out.write(template.render(path, template_values))
def test_barry_is_harry(self): harry = Person(Name("Harry", "Percival")) barry = harry barry.name = Name("Barry", "Percival") self.assertTrue(harry is barry and barry is harry)