self.template_values['user'] = self.user
self.response.headers['Cache-Control'] = 'max-age=0'
path = os.path.join(os.path.dirname(__file__), 'templates/index.html')
self.response.out.write(template.render(path, self.template_values))
清除開發服務器數據存儲區
開發網絡服務器使用本地版本的數據存儲區以通過臨時文件來測試應用程序。只要臨時文件存在,數據就存在,並且網絡服務器不會重設這些文件,除非您要求這樣做。
如果您希望開發服務器在啓動前清除其數據存儲區,請在啓動該服務器時使用 --clear_datastore
選項:
dev_appserver.py --clear_datastore helloworld/
<div class='item'>
<h2>
{{post.title}}</h2>
<p>
{{post.timestamp|date:"Y-m-d H:i:s"}}</p>
<p>
{{post.body}}</p>
</div>
def formatDate(d):
return time.strftime("%Y-%m-%d %H:%M:%S", d)
d = time.localtime()
s = formatDate(d)
print s