Exemplo n.º 1
0
	def post(self):
		result = memcache.get("getVisit")
		if result is None:
			get = Counter.all()
			result = str(get[0].todayVisit) + " " + str(get[0].totalVisit)
			if memcache.set("getVisit", result) == False:
				logging.error("Can not set memcache 'getVisit'")
		self.response.out.write(result)
Exemplo n.º 2
0
	def get(self):
		memcache.delete('getVisit')
		get = Counter.all()
		if get.count() == 0:
			use = Counter(todayVisit=0, totalVisit=0)
		else:
			use = get.get()
		if use.lastDate != datetime.date.today():
			use.todayVisit = 0
		use.todayVisit += 1
		use.totalVisit += 1
		use.put()
		tmpValue = {'todayVisit':use.todayVisit, 'totalVisit':use.totalVisit, 'myIP':self.request.remote_addr}
		path = os.path.join(os.path.dirname(__file__), '../templates/main.html')
		self.response.out.write(template.render(path, tmpValue))