Skip to content

Simple Flask extension to add Google Cloud NDB library support to flask projects

License

Notifications You must be signed in to change notification settings

bool-dev/Flask-Cloud-NDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask-Cloud-NDB

Flask-Cloud-NDB is an extension for Flask that adds support for Google Cloud NDB to your application.

Installing

Install and update using pip:

$ pip install -U Flask-Cloud-NDB

A Simple Example

from flask import Flask
from google.cloud import ndb
from flask_cloud_ndb import CloudNDB

app = Flask(__name__)
cloud_ndb = CloudNDB(app)


class Note(ndb.Model):
    title = ndb.StringProperty()
    content = ndb.StringProperty()
    created_at = ndb.DateTimeProperty()


@app.route('/')
def index():
    Note(
        title="Flask Cloud NDB with request",
        content="This is an extension, and here is an example"
        " of how to use within a request").put()

    notes = Note.query().fetch()

    return notes[0].title


# we can also simply use the context wrapper:
with cloud_ndb.context():
    Note(
        title="Flask Cloud NDB without request",
        content="This is an extension, and here is an example "
        "of how to use without request").put()
    notes = Note.query().fetch()
    print(notes[0].title)


if __name__ == '__main__':
    app.run()

Configuration Options

By default the extension will run by itself in the cloud, without any additional configurations, using the default app engine credentials.

TODOS

  • Add full configuration options description in readme
  • Add black formatting
  • Add more links to readme
  • Add more documentation to code
  • Add changes file
  • Complete manifest.in file
  • Complete setup.cfg file
  • Add tests!!
  • Add coverage
  • Build distribution for pypi

Links

About

Simple Flask extension to add Google Cloud NDB library support to flask projects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages