GAE: 使用模板、清空本地數據庫、時間

        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



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章