當 Google 宣布要支援執行階段環境中 API 的新版本時,已部署的應用程式還是會繼續使用已編寫在設定檔中的 API 版本。如要將應用程式升級來使用新的 API 版本,請變更這個值,然後將應用程式重新部署至 App Engine。如果您將這個值指定為 1,每當您部署該應用程式時,系統就會使用受支援的最新執行階段環境 (目前為 )。
目前 App Engine 有一個版本的 python27 執行階段環境:1
auto_id_policy
(非必要) 如果您要自動設定實體 ID,可以透過設定自動 ID 政策來變更所使用的方法。以下是有效的選項:
default
預設值。會使用分散的自動 ID;這些 ID 是分布均勻的大型整數,且整數小到足以由 64 位元浮點數表示。
handlers:# The root URL (/) is handled by the WSGI application named# "app" in home.py. No other URLs match this pattern.-url:/script:home.app# The URL /index.html is also handled by the home.py script.-url:/index\.htmlscript:home.app# A regular expression can map parts of the URL to the# path of the script.-url:/browse/(books|videos|tools)script:\1.catalog.app# All other URLs use the WSGI application named in "app"# in not_found.py.-url:/.*script:not_found.app
handlers:# All URLs beginning with /stylesheets are treated as paths to# static files in the stylesheets/ directory.-url:/stylesheetsstatic_dir:stylesheets# ...
handlers:# All URLs ending in .gif .png or .jpg are treated as paths to# static files in the static/ directory. The URL pattern is a# regular expression, with a grouping that is inserted into the# path to the file.-url:/(.*\.(gif|png|jpg))$static_files:static/\1upload:static/.*\.(gif|png|jpg)$# ...
[[["容易理解","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-09-01 (世界標準時間)。"],[[["\u003cp\u003eThe \u003ccode\u003eapp.yaml\u003c/code\u003e file is essential for configuring App Engine applications, defining URL mappings, and settings for each service, with the \u003ccode\u003edefault\u003c/code\u003e service requiring its \u003ccode\u003eapp.yaml\u003c/code\u003e to be created first.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eapp.yaml\u003c/code\u003e uses YAML format and allows for detailed configuration of runtime environments, including the specification of \u003ccode\u003ehandlers\u003c/code\u003e for routing requests, \u003ccode\u003eenv_variables\u003c/code\u003e, error pages, and inbound services.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ehandlers\u003c/code\u003e element within \u003ccode\u003eapp.yaml\u003c/code\u003e dictates how URLs are processed, offering options for serving static files with \u003ccode\u003estatic_dir\u003c/code\u003e and \u003ccode\u003estatic_files\u003c/code\u003e, specifying MIME types, setting HTTP headers, and redirecting HTTP/HTTPS traffic via the \u003ccode\u003esecure\u003c/code\u003e parameter.\u003c/p\u003e\n"],["\u003cp\u003eScaling configurations are managed within \u003ccode\u003eapp.yaml\u003c/code\u003e, supporting \u003ccode\u003eautomatic_scaling\u003c/code\u003e for flexible scaling based on CPU and throughput, \u003ccode\u003ebasic_scaling\u003c/code\u003e for a fixed maximum number of instances, and \u003ccode\u003emanual_scaling\u003c/code\u003e for precise control over the number of active instances.\u003c/p\u003e\n"],["\u003cp\u003eRegion ID, determined by the app's creation region, is now included in App Engine URLs for new apps, and various elements in \u003ccode\u003eapp.yaml\u003c/code\u003e such as \u003ccode\u003eapi_version\u003c/code\u003e, \u003ccode\u003ebuiltins\u003c/code\u003e, and \u003ccode\u003ethreadsafe\u003c/code\u003e have been deprecated in favor of newer methods in modern runtimes.\u003c/p\u003e\n"]]],[],null,["# App Engine app.yaml reference\n\n### Region ID\n\nThe \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e is an abbreviated code that Google assigns\nbased on the region you select when you create your app. The code does not\ncorrespond to a country or province, even though some region IDs may appear\nsimilar to commonly used country and province codes. For apps created after\nFebruary 2020, \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e`.r` is included in\nApp Engine URLs. For existing apps created before this date, the\nregion ID is optional in the URL.\n\nLearn more\n[about region IDs](/appengine/docs/legacy/standard/python/how-requests-are-routed#region-id). \nOK\n\n\u003cbr /\u003e\n\nYou configure your App Engine app's settings in the `app.yaml`\nfile.\n\nThis file specifies how URL paths correspond to request handlers and\nstatic files.\n\nThe `app.yaml` file also contains information about your\napp's code, such as the runtime and the latest version\nidentifier.\n\nEach [service](/appengine/docs/legacy/standard/python/an-overview-of-app-engine#services)\nin your app has its own `app.yaml` file, which acts as a descriptor for its\ndeployment. You must first create the `app.yaml` file for the `default` service\nbefore you can create and deploy `app.yaml` files for additional services within\nyour app.\n\n\u003cbr /\u003e\n\nDirectory structure\n-------------------\n\nTo learn more about structuring multiple services in your app, see [Structuring Web Services in App Engine](/appengine/docs/legacy/standard/python/configuration-files).\n\n\u003cbr /\u003e\n\nExample\n-------\n\nThe following is an example of an `app.yaml` file for a Python 2\napplication: \n\n```yaml\nruntime: python27\napi_version: 1\nthreadsafe: true\n\nhandlers:\n- url: /\n script: home.app\n\n- url: /index\\.html\n script: home.app\n\n- url: /stylesheets\n static_dir: stylesheets\n\n- url: /(.*\\.(gif|png|jpg))$\n static_files: static/\\1\n upload: static/.*\\.(gif|png|jpg)$\n\n- url: /admin/.*\n script: admin.app\n login: admin\n\n- url: /.*\n script: not_found.app\n```\n\nA `script:` directive can contain either a **file** path ending in `.py`, which\nmeans the script uses CGI, or a **Python module** path, with package names\nseparated by dots, which means the script uses WSGI.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nSyntax\n------\n\nThe syntax of `app.yaml` is the [YAML format](http://www.yaml.org/).\n\nThe YAML format supports comments. A line that begins with a pound (`#`)\ncharacter is ignored: \n\n # This is a comment.\n\nURL and file path patterns use [POSIX extended regular expression\nsyntax](https://wikipedia.org/wiki/Regular_expression), excluding collating\nelements and collation classes. Back-references to grouped matches (e.g. `\\1`)\nare supported, as are these Perl extensions: `\\w \\W \\s \\S \\d \\D`.\n\n### Runtime and app elements\n\n### Handlers element\n\nThe `handlers` element is a required element in the\n`app.yaml` configuration file. The element provides a list of URL\npatterns and descriptions of how they should be handled. App Engine can\nhandle URLs by executing application code, or by serving static files uploaded\nwith the code, such as images, CSS, or JavaScript.\n\nPatterns are evaluated in the order they appear in the `app.yaml` file, from\ntop to bottom. The first mapping whose pattern matches the URL is the one used\nto handle the request.\n\nThe following table lists the subelements of the `handlers` element that control\nthe behavior for scripts, static files,\nstatic directories, and other settings.\n\n### Scaling elements\n\nThe elements in following table configure how your application scales. To learn\nmore about how App Engine apps scale, see\n[Scaling types](/appengine/docs/legacy/standard/python/how-instances-are-managed#scaling_types)."]]