@app.route("/")defroot():# Store the current access time in Datastore.store_time(datetime.datetime.now(tz=datetime.timezone.utc))# Fetch the most recent 10 access times from Datastore.times=fetch_times(10)returnrender_template("index.html",times=times)
更新 templates/index.html 文件以输出每个实体的 timestamp:
<h2>Last 10 visits</h2>
{% for time in times %}
<p>{{ time['timestamp'] }}</p>
{% endfor %}
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-20。"],[[["\u003cp\u003e\u003ccode\u003eREGION_ID\u003c/code\u003e is a Google-assigned code based on the region selected when creating an app, not corresponding to a specific country or province, and it is included in App Engine URLs for apps created after February 2020.\u003c/p\u003e\n"],["\u003cp\u003eThis guide provides instructions on updating a web service to use Firestore in Datastore mode for storing and retrieving data, specifically page request data, and it is recommended to use Cloud Run for new Python web services on Google Cloud.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves using Datastore client libraries to create entities with keys and properties to store data, and retrieving the ten most recent entries based on time stamps.\u003c/p\u003e\n"],["\u003cp\u003eTo test the web service, dependencies must be installed, the web service run locally, and you can view the entities created in the Google Cloud console.\u003c/p\u003e\n"],["\u003cp\u003eOnce tested, the web service can be deployed to App Engine using the \u003ccode\u003egcloud app deploy\u003c/code\u003e command, with the next step being to integrate Firebase.\u003c/p\u003e\n"]]],[],null,[]]