Skip to content

Commit 0ec454a

Browse files
chore(gae): delete unused and add new region tags in 'standard/firebase' folder (#13131)
* chore(gae): delete unused and add new region tags in 'firebase' folder * chore(gae): update copyright header * chore(gae): delete missing END tag
1 parent e6fe9fc commit 0ec454a

File tree

5 files changed

+8
-32
lines changed

5 files changed

+8
-32
lines changed

appengine/standard/firebase/firenotes/backend/main.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class Note(ndb.Model):
4242
created = ndb.DateTimeProperty(auto_now_add=True)
4343

4444

45-
# [START gae_python_query_database]
4645
def query_database(user_id):
4746
"""Fetches all notes associated with user_id.
4847
@@ -67,22 +66,17 @@ def query_database(user_id):
6766
return note_messages
6867

6968

70-
# [END gae_python_query_database]
71-
72-
7369
@app.route("/notes", methods=["GET"])
7470
def list_notes():
7571
"""Returns a list of notes added by the current Firebase user."""
7672

7773
# Verify Firebase auth.
78-
# [START gae_python_verify_token]
7974
id_token = request.headers["Authorization"].split(" ").pop()
8075
claims = google.oauth2.id_token.verify_firebase_token(
8176
id_token, HTTP_REQUEST, audience=os.environ.get("GOOGLE_CLOUD_PROJECT")
8277
)
8378
if not claims:
8479
return "Unauthorized", 401
85-
# [END gae_python_verify_token]
8680

8781
notes = query_database(claims["sub"])
8882

@@ -91,8 +85,7 @@ def list_notes():
9185

9286
@app.route("/notes", methods=["POST", "PUT"])
9387
def add_note():
94-
"""
95-
Adds a note to the user's notebook. The request should be in this format:
88+
"""Adds a note to the user's notebook. The request should be in this format:
9689
9790
{
9891
"message": "note message."
@@ -107,7 +100,6 @@ def add_note():
107100
if not claims:
108101
return "Unauthorized", 401
109102

110-
# [START gae_python_create_entity]
111103
data = request.get_json()
112104

113105
# Populates note properties according to the model,
@@ -116,7 +108,6 @@ def add_note():
116108

117109
# Some providers do not provide one of these so either can be used.
118110
note.friendly_id = claims.get("name", claims.get("email", "Unknown"))
119-
# [END gae_python_create_entity]
120111

121112
# Stores note in database.
122113
note.put()

appengine/standard/firebase/firenotes/frontend/main.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// Copyright 2016, Google, Inc.
1+
// Copyright 2016 Google LLC
2+
//
23
// Licensed under the Apache License, Version 2.0 (the "License");
34
// you may not use this file except in compliance with the License.
45
// You may obtain a copy of the License at
56
//
6-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// https://www.apache.org/licenses/LICENSE-2.0
78
//
89
// Unless required by applicable law or agreed to in writing, software
910
// distributed under the License is distributed on an "AS IS" BASIS,
@@ -19,7 +20,6 @@ $(function(){
1920
// backend's app.yaml file.
2021
var backendHostUrl = '<your-backend-url>';
2122

22-
// [START gae_python_firenotes_config]
2323
// Obtain the following from the "Add Firebase to your web app" dialogue
2424
// Initialize Firebase
2525
var config = {
@@ -30,7 +30,6 @@ $(function(){
3030
storageBucket: "<BUCKET>.appspot.com",
3131
messagingSenderId: "<MESSAGING_SENDER_ID>"
3232
};
33-
// [END gae_python_firenotes_config]
3433

3534
// This is passed into the backend to authenticate the user.
3635
var userIdToken = null;
@@ -40,7 +39,6 @@ $(function(){
4039

4140
firebase.initializeApp(config);
4241

43-
// [START gae_python_state_change]
4442
firebase.auth().onAuthStateChanged(function(user) {
4543
if (user) {
4644
$('#logged-out').hide();
@@ -67,11 +65,9 @@ $(function(){
6765

6866
}
6967
});
70-
// [END gae_python_state_change]
7168

7269
}
7370

74-
// [START gae_python_firebase_login]
7571
// Firebase log-in widget
7672
function configureFirebaseLoginWidget() {
7773
var uiConfig = {
@@ -91,9 +87,7 @@ $(function(){
9187
var ui = new firebaseui.auth.AuthUI(firebase.auth());
9288
ui.start('#firebaseui-auth-container', uiConfig);
9389
}
94-
// [END gae_python_firebase_login]
9590

96-
// [START gae_python_fetch_notes]
9791
// Fetch notes from the backend.
9892
function fetchNotes() {
9993
$.ajax(backendHostUrl + '/notes', {
@@ -110,7 +104,6 @@ $(function(){
110104
});
111105
});
112106
}
113-
// [END gae_python_fetch_notes]
114107

115108
// Sign out a user
116109
var signOutBtn =$('#sign-out');

appengine/standard/firebase/firetactoe/firetactoe.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def make_move(self, position, user):
202202
return
203203

204204

205+
# [START gae_standard_firebase_move_route]
205206
# [START move_route]
206207
@app.route("/move", methods=["POST"])
207208
def move():
@@ -211,12 +212,10 @@ def move():
211212
return "Game not found, or invalid position", 400
212213
game.make_move(position, users.get_current_user())
213214
return ""
214-
215-
216215
# [END move_route]
216+
# [END gae_standard_firebase_move_route]
217217

218218

219-
# [START route_delete]
220219
@app.route("/delete", methods=["POST"])
221220
def delete():
222221
game = Game.get_by_id(request.args.get("g"))
@@ -227,9 +226,6 @@ def delete():
227226
return ""
228227

229228

230-
# [END route_delete]
231-
232-
233229
@app.route("/opened", methods=["POST"])
234230
def opened():
235231
game = Game.get_by_id(request.args.get("g"))
@@ -258,6 +254,7 @@ def main_page():
258254
game.userO = user
259255
game.put()
260256

257+
# [START gae_standard_firebase_pass_token]
261258
# [START pass_token]
262259
# choose a unique identifier for channel_id
263260
channel_id = user.user_id() + game_key
@@ -285,3 +282,4 @@ def main_page():
285282

286283
return flask.render_template("fire_index.html", **template_values)
287284
# [END pass_token]
285+
# [END gae_standard_firebase_pass_token]

appengine/standard/firebase/firetactoe/rest_api.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from functools import lru_cache
1919
except ImportError:
2020
from functools32 import lru_cache
21-
# [START rest_writing_data]
2221
import json
2322

2423
import google.auth
@@ -85,9 +84,6 @@ def firebase_post(path, value=None):
8584
return json.loads(content)
8685

8786

88-
# [END rest_writing_data]
89-
90-
9187
def firebase_get(path):
9288
"""Read the data at the given path.
9389

appengine/standard/firebase/firetactoe/static/main.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,11 @@ function initGame(gameKey, me, token, channelId, initialMessage) {
132132
* finally, it calls onOpened() to let the server know it is ready to receive messages
133133
*/
134134
function openChannel() {
135-
// [START auth_login]
136135
// sign into Firebase with the token passed from the server
137136
firebase.auth().signInWithCustomToken(token).catch(function(error) {
138137
console.log('Login Failed!', error.code);
139138
console.log('Error message: ', error.message);
140139
});
141-
// [END auth_login]
142140

143141
// setup a database reference at path /channels/channelId
144142
channel = firebase.database().ref('channels/' + channelId);

0 commit comments

Comments
 (0)