def post(self): user = users.get_current_user() logout_url = users.create_logout_url("/") api_key = gen_short_key() account_name = self.request.get("account_name") description = self.request.get("description") expires = datetime.strptime(self.request.get("expires"),"%Y-%m-%d") account_number = self.request.get("account_number") email = self.request.get("email") key = API_KEY(api_key=api_key, account_name=account_name, description=description, expires=expires, account_number=account_number,email=email) key.save() api_keys = API_KEY.all() path = os.path.join(os.path.dirname(__file__), 'admin.html') self.response.out.write(template.render(path, {'api_keys':api_keys, 'message':"API Key Created.", 'user':user, 'logout_url':logout_url}))
def get(self): api_key_str = self.request.get('api_key') api = API_KEY.all().filter('api_key =', api_key_str) if api.count()==0: self.render_template("info.html", {}) elif api[0].expires < datetime.now(): self.render_template("expired.html", {}) else: api=api[0] request_count = api.request_count api.request_count = request_count + 1 api.save() user_agent = self.request.get('UA', None) if not user_agent: user_agent = str(self.request.headers['User-Agent']) logging.info("User agent is: %s" % user_agent) redirect = "None" for p in self.request.arguments(): if p.upper() in user_agent.upper(): redirect = self.request.get(p) m = MobileRedirect(parameter_string=self.request.query_string, user_agent = user_agent, resulting_url = redirect, api_key=api_key_str) m.put() if redirect=="None": redirect = self.request.get('DEFAULT', "NoDefault") if redirect == "NoDefault": render_template("info.html", {}) #path = os.path.join(os.path.dirname(__file__), 'info.html') #self.response.out.write(template.render(path, {})) else: logging.info("Redirecting to %s" % redirect) self.redirect(str(redirect))
def get(self): user = users.get_current_user() logout_url = users.create_logout_url("/") api_keys = API_KEY.all() path = os.path.join(os.path.dirname(__file__), 'admin.html') self.response.out.write(template.render(path, {'api_keys':api_keys, 'user':user, 'logout_url':logout_url}))