pgltsmn / Firebase-Realtime-Database-Lab

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Firebase Realtime Database

Objective:

In this lab, you will learn about reading, adding, editing and deleting info from a realtime database! As well as the structure of the database.

Before we start, make sure to go to open the folder from the previous lab, and continue to work there.

Twitter Lab:

  1. Setting up Realtime Database in Firebase:

    1. Go to your console and choose your project.
    2. Go to Realtime Database and create a database.
    3. Go to rules and change false to true.
    4. Make sure to copy the database's link.
  2. Setting up Realtime Database in app.py:

    1. In the config dictionary add databaseURL as a key and the link you copied as the value.
    2. Intialize the 'db' using the firebase object.
  3. Add in signup.html 3 inputs:

    1. full_name
    2. username
    3. bio - It should take a maximum of 280 letters.
  4. When the user signs up:

    • Create a dictionary called user that contains the inputs' name as keys and and the inputs as values.
    • Add the user to the database through the child Users adding him through his uid (retrieve it through login_session).
  5. Create a form in add_tweet.html to add a tweet to the database:

    • The form should contain:
      • Title.
      • Text- It should take a maximum of 280 letters.
      • Don't forget to add action and method
  6. When the user submits a tweet:

    • Create a dictionary called tweet that contains the inputs' name as keys and the inputs as values.
    • In the dictionary add a key named uid and the value as the uid of the user that wrote the tweet.
    • Add the tweet using the child Tweets to the database with a random key (the push method).
  7. Create an html page called tweets.html & a route called /all_tweets:

    • in this html page display all the tweets that were written:
      • Go to the child Tweets and use get().val()
Great job!
Call an Instructor/TA to check your completed tasks

If you have extra time, continue to the Bonus Problems below.
If not, make sure your code is pushed.

Bonus Problems:

  1. Add a Tweet Timestamp attribute! It should take the real time and date and save it in Tweet.

  2. Add a like button:

    • It should add 1 like to a specific tweet, everytime a like button has been clicked using the database.
Great job on completing the bonus problems section!
Make sure your code is pushed to GitHub!

About