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.
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:
- Visit this link: Firebase
- Log in with the Google ID & Password. You will be landed on the screen below.
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.
4. After that enter your project name as shown below, and follow the further steps to set up the project.
After the project creation, you will be landed on a page as shown below.
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.
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.
This Ansible role is used to configure the Apache webserver with a test PHP file which will show the IPAddress of the…
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.
Congratulations on successfully building the limited edition rare project!
Example Outputs from this Project!
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!