Git Product home page Git Product logo

flask-firebase-crud's Introduction

flask-firebase-crud

Flask App with Firebase connectivity - Firebase Setup - Firebase default app initialization - CRUD Operations using ToDo collection - Flask Setup & APIs to do crud operations

Create APP on Firebase

- Create Realtime database
- Generate API Key (Python)
- Put it on working directory (Also add the file to .gitignore)

Install firebase-admin

- pip install firebase-admin

Install flask modules

- pip install flask
- pip install flask-restful
- pip install flask-cors

Appsettings File

I have use appsettings.json file to store configuration items
    - DatabaseURL
    - Collection Details

This file contains connectivity of Firebase and sample CRUD operations using TODO List - Class ToDoCollection() - Initialize reference for todo collection

Methods Description Input Output Access
_getSnapshot() To get snapshot of collection None dict or None Private
__findItem(id) To find the item id: 1 dict or False Private
addTodoItem(content) To push/add new todo items into collection dict: {'id':1, 'task':'Task'} Boolean Public
getTodoItems() To get the entire todo items list None list Public
getTodoItem() To get the todo item id: 1 dict or None Public
clearAllItems() To clear all nodes in the collection None Boolean Public
updateTodoItem(self, id, content) To update item from the collection id: 1, dict: {'id':1, 'task':'Task'} Boolean Public
deleteTodoItem(id) To delete item from the collection id: 1 Boolean Public

Main python file run as Flask Restful API application

- Added CORS Policy to the Flask App
- Created APIs as Restful

APIs Used in app.py - Flask Application

API URL Description METHOD Body Content(Eg.)
/health Check whether the application is running properly or not GET None
/getAllItems Return all the todo items GET None
/getItem Return the todo item POST {"id": 1}
/addItem Add new todo item to the collection POST {"id": 1 , "task": "My Todo task"}
/deleteItem Delete todo item from the collection DELETE {"id": 1}
/deleteAllItems Delete all the items from the collection DELETE None
/updateItem Delete all the items from the collection POST {"id": 1 , "task": "My Todo task"}
- Success API call will have status code of 200
- Failure and exception API with return with status code 400

Thanks everyone

flask-firebase-crud's People

Contributors

jeganathpv avatar

Stargazers

Axel Alexander avatar María José Pérez Borré avatar Akshay Kushawaha avatar Vitoria avatar  avatar Abbashozefa avatar Francis Githae avatar pdvvhqr avatar Omkar Chalke avatar Sydney Twigg avatar Ollie avatar Manuel Ortigoza avatar Daniel Pepuho avatar Mateus Melo avatar kadirtaban avatar Andrea V. avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.