Imposta la variabile di ambiente ENDPOINTS_GAE_SDK sul percorso della directory dell'SDK App Engine:Path_to_Cloud_SDK/platform/google_appengine.
Sostituisci Path_to_Cloud_SDK con l'output del
seguente comando:
gcloudinfo--format="value(installation.sdk_root)"
Esegui il seguente comando nella directory principale dell'API:
gcloudappdeploy
Attendi qualche istante affinché il deployment vada a buon fine, ignorando i messaggi di avviso. Al termine del deployment, viene visualizzato un messaggio simile al seguente:
File upload done.
Updating service [default]...done.
Conferma il deployment riuscito inviando una richiesta di test all'API, ad esempio:
Puoi utilizzare il server di sviluppo locale App Engine per testare la tua API
localmente. Per ulteriori informazioni sul server di sviluppo locale, consulta Utilizzare il server di sviluppo locale.
Per eseguire l'API localmente:
Dalla directory principale del progetto, avvia il server di sviluppo App Engine:
dev_appserver.py YOUR_PROJECT_DIR
Esegui curl per inviare una richiesta API, ad esempio:
Affinché la tua API venga gestita dai framework Endpoints, devi generare e implementare un documento OpenAPI che la descriva, come descritto in Aggiunta della gestione delle API.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eThis guide details the process of deploying an API, which includes setting up the environment, creating the API and web server, and then deploying to production.\u003c/p\u003e\n"],["\u003cp\u003eTo deploy to production, you must set the \u003ccode\u003eENDPOINTS_GAE_SDK\u003c/code\u003e environment variable and use the \u003ccode\u003egcloud app deploy\u003c/code\u003e command, then confirm deployment by making a test request.\u003c/p\u003e\n"],["\u003cp\u003eAPIs can be tested locally using the App Engine development server, started via \u003ccode\u003edev_appserver.py YOUR_PROJECT_DIR\u003c/code\u003e, followed by sending a test \u003ccode\u003ecurl\u003c/code\u003e request.\u003c/p\u003e\n"],["\u003cp\u003eEndpoints Frameworks offers API management features, such as monitoring, logging, quotas, and a developer portal, which are enabled by deploying an OpenAPI document.\u003c/p\u003e\n"],["\u003cp\u003eVersioning can be done by referring to the "Handling API versioning" page.\u003c/p\u003e\n"]]],[],null,["# Deploying and testing an API\n\nThis page describes how to deploy your API.\n\nBefore you begin\n----------------\n\n- [Set up your programming environment and download tools](/endpoints/docs/frameworks/python/get-started-frameworks-python#before-you-begin).\n- [Create your API](/endpoints/docs/frameworks/python/create_api).\n- [Create a web server](/endpoints/docs/frameworks/python/api_server) to serve your API.\n\nDeploying your API to production\n--------------------------------\n\nTo deploy an API:\n\n1. Set the `ENDPOINTS_GAE_SDK` environment variable to the path of your\n App Engine SDK folder:\n \u003cvar translate=\"no\"\u003ePath_to_Cloud_SDK\u003c/var\u003e`/platform/google_appengine`.\n\n Replace \u003cvar translate=\"no\"\u003ePath_to_Cloud_SDK\u003c/var\u003e with the output of the\n following command: \n\n gcloud info --format=\"value(installation.sdk_root)\"\n\n2. Run the following command in the API main directory:\n\n gcloud app deploy\n\n Wait a few moments for the deployment to succeed, ignoring the warning\n messages. When the deployment completes, a message similar to the\n following displays: \n\n ```\n File upload done.\n Updating service [default]...done.\n ```\n3. Confirm successful deployment by sending a test request to the API, for\n example:\n\n ```\n curl --request POST \\\n --header \"Content-Type: application/json\" \\\n --data '{\"content\":\"echo\"}' \\\n https://PROJECT_ID.appspot.com/_ah/api/echo/v1/echo?n=2\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your project ID and\n `echo` with your API name.\n\n The results are: \n\n ```\n {\n \"content\": \"echo echo\"\n }\n ```\n\nIf you didn't get a successful response, see\n[Troubleshooting response errors](/endpoints/docs/frameworks/troubleshoot-response-errors).\n\nDeploying to multiple app versions\n----------------------------------\n\nFor information on how to do API versioning, and how to deploy to versions,\nsee [Handling API versioning](/endpoints/docs/frameworks/python/handling-api-versioning)\n\nTesting an API locally\n----------------------\n\nYou can use the App Engine local development server to test your API\nlocally. For more information about the local development server, see\n[Using the local development server](/appengine/docs/standard/python/tools/using-local-server).\n\nTo run your API locally:\n\n1. From the root directory of the project, start the App Engine\n development server:\n\n ```\n dev_appserver.py YOUR_PROJECT_DIR\n ```\n2. Run `curl` to make an API request, for example:\n\n curl --request POST \\\n --header \"Content-Type: application/json\" \\\n --data '{\"message\":\"echo\"}' \\\n \"${HOST}/_ah/api/echo/v1/echo?n=2\"\n\nAdding API management\n---------------------\n\nEndpoints Frameworks provides API management features such as:\n\n- [Monitoring](/endpoints/docs/frameworks/monitoring-your-api)\n- [Logging](/endpoints/docs/frameworks/monitoring-your-api#logs)\n- [Quotas](/endpoints/docs/openapi/quotas-overview)\n- [Developer portal](/endpoints/docs/openapi/dev-portal-overview)\n\nFor your API to be managed by Endpoints Frameworks, you must generate\nand deploy an OpenAPI document that describes your API, as described in\n[Adding API management](/endpoints/docs/frameworks/python/adding-api-management)."]]