Note for running this in local development server. You need to use install a older version of Pillow or PIL in order to use the image library. I tested this with Pillow 2.9 as suggested in here
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime: python27 | |
api_version: 1 | |
threadsafe: true | |
handlers: | |
- url: / | |
script: main.app | |
- url: /(.*) | |
script: main.app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require('firebase-functions'); | |
// Create a function that trigger by HTTP | |
exports.helloWorld = functions.https.onRequest((request, response) => { | |
// console.log/info/warn/error will send the message to Cloud Logging | |
console.log('In helloworld!'); | |
response.send("Hello from Firebase!"); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def htmlsafe_json_dumps(obj, dumper=None, **kwargs): | |
"""Works exactly like :func:`dumps` but is safe for use in ``<script>`` | |
tags. It accepts the same arguments and returns a JSON string. Note that | |
this is available in templates through the ``|tojson`` filter which will | |
also mark the result as safe. Due to how this function escapes certain | |
characters this is safe even if used outside of ``<script>`` tags. | |
The following characters are escaped in strings: | |
- ``<`` | |
- ``>`` | |
- ``&`` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import webapp2 | |
import logging | |
from google.appengine.ext import ndb | |
@ndb.transactional(retries=10) | |
def update_bank_account(key, by=1): | |
account = BankAccount.get_by_id(key) | |
if account: | |
account.amount += by | |
account.put() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import webapp2 | |
from google.appengine.ext import ndb | |
class BankAccount(ndb.Model): | |
amount = ndb.IntegerProperty(default=0) | |
redirect_html = '''<html> | |
<head> |