Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Name of Current App in Google App Engine (Python)

Using the Google App Engine Python API is there a way to access the name of the currently running application--i.e., the app name specified in your app.yaml file with application: foobar?

like image 679
Chris W. Avatar asked May 05 '11 17:05

Chris W.


People also ask

What are the applications of Google App Engine?

App Engine is a fully managed, serverless platform for developing and hosting web applications at scale. You can choose from several popular languages, libraries, and frameworks to develop your apps, and then let App Engine take care of provisioning servers and scaling your app instances based on demand.

Is Python used in App Engine?

NET applications, Google App Engine enables users to develop and host applications written using Java, Python and a new language called Go [25]. The platform also supports other languages that use JVM (Java Virtual Machine) runtime such as JRuby, JavaScript (Rhino), and Scala programming languages.

What is the currently preferred version of Python for App Engine?

Python 3.10 is now generally available.


1 Answers

import os
appname = os.environ['APPLICATION_ID']

EDIT: I just noticed this because I got a new upvote on it today (shame on you, upvoter!), but this is no longer correct.

from google.appengine.api.app_identity import get_application_id
appname = get_application_id()

should be used. The value in os.environ will include a "s~" prefix for applications using the HR datastore and, by default, "dev~" on the development server. (os.environ should also be avoided entirely on App Engine anyway, since when concurrency support is added with the Python 2.7 runtime, use of os.environ won't be threadsafe and will allow data to leak from one request to another, although obviously the application ID itself would be the same for multiple requests to the same application at the same time...)

like image 50
Wooble Avatar answered Oct 31 '22 03:10

Wooble