def get(self, file_name): static_file = StaticFile.query(StaticFile.name==file_name).get() if not static_file: self.abort(404) else: self.response.write(static_file.content) self.response.set_status(200) self.response.headers['Content-Type'] = str(static_file.content_type) self.response.headers['Access-Control-Allow-Origin'] = '*'
def post(self, file_name): static_file = StaticFile.query(StaticFile.name==file_name).get() if not static_file: static_file = StaticFile(name=file_name) static_file.content = self.request.body static_file.content_type = self.get_content_type( self.request.headers, file_name) static_file.put() self.response.headers['Content-Type'] = 'text/plain' self.response.set_status(204)