Integrating Firebase & Linux Commands API using Flutter!

This blog explains the process of integrating Linux API with Firebase using Flutter. In this integration, any Linux command will be executed using Flutter App which will fetch the command output from Linux Webserver & store the output at the Firestore. The flutter app developed will also have the functionality to retrieve the data from the Firestore.

Image for post
Image for post

Ever thought of creating an application that provides you the capability to run the Linux commands from your mobile phone, store their output in Firestore(Google NoSQL Database) & can retrieve outputs of all those commands? How amazing it will be to create such an app, as it will provide ease & simplicity to your life. This blog aims to guide you with the complete process.

There are no pre-requisites for the complete practical. This blog covers every aspect of the practical, i.e. from creating a document in Firestore & creating an API, to connect them by flutter Application.

Setting Up Firestore:

To accomplish this part of the practical, follow the steps given below:

  1. Visit this link: Firebase
  2. Log in with the Google ID & Password. You will be landed on the screen below.
Image for post
Image for post

3. Click on the “Go to console” & then you will be landed on the Firebase homepage. Click on the button given below to add one project.

Image for post
Image for post

4. After that enter your project name as shown below, and follow the further steps to set up the project.

Image for post
Image for post

After the project creation, you will be landed on a page as shown below.

Image for post
Image for post

5. Now click on the Android Icon shown on the above page and follow the complete process, it will guide you to set up or connect your Flutter App to Firestore. For completion of this step, create one sample flutter app and follow the complete process till here.

Creating API

The API creation code is shown below. (This code will create one API which will help to run the Linux Commands using a webserver).

Note: For this API code to work, Apache webserver(httpd) has to be installed in your machine. To do the same, either follow the standard procedure or use my Ansible role to configure it if you have some knowledge of Ansible & using RedHat Linux. The link to my Ansible Role is given below.

API Code

Write this code in a file, save it with “.py” extension in the folder “/var/www/cgi-bin”.

Make this file executable by running the command “chmod +x <filename>”.

Creating the Flutter App!

Note: For the above code to work, add the following dependencies to your pubspec.yaml file.

Image for post
Image for post

Congratulations on successfully building the limited edition rare project!

Example Outputs from this Project!

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

I hope my article explains each and everything related to the topic with all the deep concepts and explanations. Thank you so much for investing your time in reading my blog & boosting your knowledge!

Written by

Big Data Enthusiast, have a demonstrated history of delivering large and complex projects. Interested in working in the field of AI and Data Science.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store