I am new to python and Google App Engine. I am trying to reorganize this code from Nick Johnson's blog to use webapp2 and python 2.7. http://blog.notdot.net/2009/10/Blogging-on-App-Engine-part-1-Static-serving
Anyway, when I run the code below, I get this error.
TypeError: get () takes exactly 2 arguments (1 given)
I think this may have something to do with a path variable that is not defined, but I don't know how to define it.
import webapp2
from google.appengine.ext import webapp
from google.appengine.ext import db
class StaticContent(db.Model):
body = db.BlobProperty()
content_type = db.StringProperty(required=True)
last_modified = db.DateTimeProperty(required=True, auto_now=True)
def get(path):
return StaticContent.get_by_key_name(path)
def set(path, body, content_type, **kwargs):
content = StaticContent(
key_name=path,
body=body,
content_type=content_type,
**kwargs)
content.put()
return content
class MainHandler(webapp2.RequestHandler):
def get(self, path):
content = get(path)
if not content:
self.error(404)
return
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
source
share