Définissez la variable d'environnement ENDPOINTS_GAE_SDK sur le chemin d'accès de votre dossier SDK App Engine : Path_to_Cloud_SDK/platform/google_appengine.
Remplacez Path_to_Cloud_SDK par le résultat de la commande suivante :
gcloudinfo--format="value(installation.sdk_root)"
Exécutez la commande suivante dans le répertoire principal de l'API :
gcloudappdeploy
Attendez que le déploiement soit terminé et ignorez les messages d'avertissement. Un message semblable à celui-ci s'affiche alors :
File upload done.
Updating service [default]...done.
Vérifiez que le déploiement a abouti en envoyant une requête de test à l'API, par exemple :
Pour en savoir plus sur la procédure de gestion des versions d'API et sur le déploiement vers différentes versions, consultez la page Gérer les versions d'une API.
Tester une API en local
Vous pouvez utiliser le serveur de développement local App Engine pour tester votre API localement. Pour en savoir plus sur le serveur de développement local, consultez la page Utiliser le serveur de développement local.
Pour exécuter votre API en local :
Depuis le répertoire racine du projet, démarrez le serveur de développement App Engine :
dev_appserver.py YOUR_PROJECT_DIR
Exécutez curl pour effectuer une requête d'API, par exemple :
Pour que votre API soit gérée par Endpoints Frameworks, vous devez générer et déployer un document OpenAPI décrivant votre API, comme indiqué dans la page Ajouter la gestion des API.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)."]]