Flutter Python: Firebase like backend in Flutter using Python! (MongoDB and WebSocket)

Published by Abhay Rastogi on

Flutter Python Backend

Create a rest API using Python with MongoDB, then notify changes through WebSocket in a flutter. In this flutter python blog, we will implement Rxdart for making HTTP request Reactive.

In this, we will not deal with model classes in Flutter as I tried to make it as like as the firebase database backend.

Before diving into code make sure of installing the following for backend!

Create a new project in Pycharm then Install dependencies in python project.in this project, we will use Aiohttp server for python

Websocket notify any changes made in the database, data will be pass-through socket.emit() and socket.on() will listen.

  • socket.emit() to emit data to an event.
  • socket.on() get data from emit.

Create new python file api.py and check if the server is running properly!

Type terminal python api.py to run this file then check http://localhost:8080/apitest in postman

As server is running properly, let’s add MongoDB in and create two functions one for adding data in database and second one for fetching data.

Now create new flutter project and install these dependencies in pubspec.yaml

create service.dart and make sure of giving the exact hosted IP address of your machine before port address.

Show data in list view in main.dart!


2 Comments

Cesar Gonzalez · 27th January 2020 at 9:28 pm

very, very nice. I’ll make a try

Flutter Python: Firebase like backend in Flutter using Python! (MongoDB and WebSocket) – Flutter 포털 · 4th March 2020 at 8:08 am

[…] View Reddit by abhay994 – View Source […]

Leave a Reply

Your email address will not be published. Required fields are marked *