D. Storing the Images📤 and User Feedback Online
Setting up Firebase
-
Login in to Firebase, using your Gmail ID.
-
Click on the
Get Startedbutton which will, take you to your console.
Creating a project
-
Click on
Add project. Once you do so, a 3 Step process will start. -
Enter the name of your project. (Pro tip: Keep the same name as the name of your App. It would make it easier to identify.)
-
The next step is pretty self explanatory and you may/may not choose to enable google analytics.
-
If you choose to enable google analytics, then you will have to select or create a Google Analytics account.
-
If you choose not to, then a
Create projectbutton will appear instead of Continue.
-
-
Once you click on
Create project, you will land on Firebase Console.
Setting up Storage
-
Once you land on the Firebase Console, click on the
Create Web Appicon. -
Give the name of your web app and unless required, do not select the Hosting option and click
next. -
Copy the code which appears and store in a
config.txtfile for later use. -
Click on
Continue to Console. -
Once on Console, click on the
StorageOption on the left panel and then click onGet Started. -
Click
Nextand then select a server closest to your location. -
Once the Storage is initiated, click on the
Rulestab and change:allow read, write: if request.auth != null;toallow read, write;in the code snippet which appears on the screen.Note: This is only for testing purposes and in real life scenarios refrain from doing this.
-
This change basically allows us the upload and download the images without authenticating every time.
-
With this you have set up the Storage successfully. You can manage your app's cloud server from here.
Setting up Realtime Database
-
Click on the
Realtime DatabaseOption on the left panel. -
Once on the page, click on
Create Databasebutton. -
When you click the button, there will be a prompt to set the Security rules. It is recommended to start in locked mode so as to ensure security of the data.
-
With this you have set up the Database successfully. Now whenever a user writes a feedback, you can check it here in this database. Since this database stores data in terms of
JSONfiles, you can also export the JSON file and use it in whichever way you like.
Linking Firebase in the App
Since everything is set up in the Firebase Console, the only thing left to do is to link the services to your app. You can do it this way:
-
Open
firebase_bro.py -
Remember the
config.txtfile which we created earlier? Open it up and copy the contents offirebaseConfigintoconfigvariable insidefirebase_bro.py. -
Save the File.
Voila! You have Successfully set up Firebase into your app!
Removing FIREBASEđź‘‹đź‘‹
If you do not want to use firebase please feel free to:
-
Remove the
firebase_bro.pyfile from the current working directory -
Delete the following lines from the
app.pyfile:-
import firebase_bro. -
firebase_bro.send_img(image)line inside theHomeblock of the if else condition. -
firebase_bro.send_feedback(first_name, last_name, user_email, feedback)line inside theFeedbackblock of the if else condition.
-
-
Also remove
firebaseand all the lines below the commentFor Handling firebase and pyrebase dependency issuesin therequirements.txt
REMEMBER: The current version of the app only supports jpg, png and jpeg images as input