Esempio n. 1
0
	def get(self, hash):
		# The request parses the hash from the path by slicing the string to omit
		# the leading "\". We ask the datastore for any entity that matches the hash.
		url = Url.get_by_key_name(hash)

		# If the hash is valid it will return Url Model object else it will return None
		if url:
			# The successul return of a url object allows the application to return a 
			# redirct (301) to the long url.
			self.redirect(str(url.link))
		else:
			# If there is no short url it is proper to return a 404 as the resource is
			# not available.
			self.abort(404)