@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"]],["上次更新時間:2025-08-19 (世界標準時間)。"],[[["\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,[]]