运行dev_appserver.py时如何配置应用名称?
application from app.yaml Great question! Now that Google recommends ditching the application element in app.yaml and using command-line flags for production deployment, here's how to handle specifying your app/project ID for the local dev_appserver.py tool:
Use command-line flags directly
Just like with deployment tools, you can pass the app ID via the--application(or shorthand-A) flag when starting the local server:dev_appserver.py --application [YOUR_PROJECT_ID] app.yaml # Or the shorter version: dev_appserver.py -A [YOUR_PROJECT_ID] app.yamlThis is the most explicit approach and aligns with the command-line pattern recommended for production deployments.
Set an environment variable
If you don't want to type the flag every time, set theGCLOUD_PROJECTenvironment variable—dev_appserver.pywill automatically pick up this value:- On Linux/macOS:
export GCLOUD_PROJECT=[YOUR_PROJECT_ID] dev_appserver.py app.yaml - On Windows (Command Prompt):
set GCLOUD_PROJECT=[YOUR_PROJECT_ID] dev_appserver.py app.yaml - On Windows (PowerShell):
$env:GCLOUD_PROJECT = "[YOUR_PROJECT_ID]" dev_appserver.py app.yaml
- On Linux/macOS:
A quick note on legacy configs
If you haven't fully removed theapplicationelement fromapp.yamlyet,dev_appserver.pywill prioritize the command-line flag or environment variable over the config file value. For consistency with production best practices, though, it's still recommended to remove theapplicationentry entirely.
内容的提问来源于stack exchange,提问作者jacob

