├── Auth
├── app.py
└── templates
│ └── new.html
├── README.md
├── RealTimeDatabase
├── app.py
└── templates
│ └── index.html
└── Storage
├── app.py
├── example.jpg
├── image.jpg
├── static
└── cover.css
└── templates
├── index.html
└── upload.html
/Auth/app.py:
--------------------------------------------------------------------------------
1 | import pyrebase
2 | from flask import *
3 | app = Flask(__name__)
4 | config = {
5 | "apiKey": "",
6 | "authDomain": "",
7 | "databaseURL": "",
8 | "projectId": "",
9 | "storageBucket": "",
10 | "messagingSenderId": ""
11 | }
12 |
13 | firebase = pyrebase.initialize_app(config)
14 |
15 | auth = firebase.auth()
16 |
17 | @app.route('/', methods=['GET', 'POST'])
18 |
19 | def basic():
20 | unsuccessful = 'Please check your credentials'
21 | successful = 'Login successful'
22 | if request.method == 'POST':
23 | email = request.form['name']
24 | password = request.form['pass']
25 | try:
26 | auth.sign_in_with_email_and_password(email, password)
27 | return render_template('new.html', s=successful)
28 | except:
29 | return render_template('new.html', us=unsuccessful)
30 |
31 | return render_template('new.html')
32 |
33 |
34 | if __name__ == '__main__':
35 | app.run()
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/Auth/templates/new.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | {% if s %}
16 |
17 |
{{s}}
18 |
19 | {% endif %}
20 |
21 | {% if us %}
22 |
23 |
{{us}}
24 |
25 | {% endif %}
26 |
27 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Python and Firebase with Deployment
2 |
3 | This repository is having files covered in the tutorials on YouTube.
4 | Implementation is done using the Pyrebase, which is a simple wrapper for Firebase API to interact with Python.
5 | To make this interesting I've used the Flask Framework.
6 |
7 | ## Using the Repo
8 |
9 | First go through the tutorials on my YouTube channel in this playlist
10 | ###### Follow the steps given below
11 | 1. Clone this repository using command ~
12 | ```
13 | git clone https://github.com/kanuarj/FirebasePython.git
14 | cd FirebasePython
15 | ```
16 |
17 | 2. Install required python packages ~
18 | ```
19 | pip install flask pyrebase
20 | ```
21 |
22 | 3. Follow tutorials and experiment with code.
23 |
24 | 4. Subscribe to my YouTube channel.
25 |
26 | Happy Learning. Peace.
27 |
--------------------------------------------------------------------------------
/RealTimeDatabase/app.py:
--------------------------------------------------------------------------------
1 | import pyrebase
2 |
3 | config = {
4 | "apiKey": "",
5 | "authDomain": "",
6 | "databaseURL": "",
7 | "projectId": "",
8 | "storageBucket": "",
9 | "messagingSenderId": ""
10 | }
11 |
12 | firebase = pyrebase.initialize_app(config)
13 |
14 | db = firebase.database()
15 |
16 | from flask import *
17 |
18 | app = Flask(__name__)
19 |
20 | @app.route('/', methods=['GET', 'POST'])
21 | def basic():
22 | if request.method == 'POST':
23 | if request.form['submit'] == 'add':
24 |
25 | name = request.form['name']
26 | db.child("todo").push(name)
27 | todo = db.child("todo").get()
28 | to = todo.val()
29 | return render_template('index.html', t=to.values())
30 | elif request.form['submit'] == 'delete':
31 | db.child("todo").remove()
32 | return render_template('index.html')
33 | return render_template('index.html')
34 |
35 | if __name__ == '__main__':
36 | app.run(debug=True)
37 |
38 |
39 |
--------------------------------------------------------------------------------
/RealTimeDatabase/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
15 |
21 |
22 |
23 |
24 |
25 | {% for l in t %}
26 |
27 | -
28 | {{l}}
29 |
30 |
31 | {% endfor %}
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Storage/app.py:
--------------------------------------------------------------------------------
1 | import pyrebase
2 |
3 | config = {
4 | "apiKey": "",
5 | "authDomain": "",
6 | "databaseURL": "",
7 | "projectId": "",
8 | "storageBucket": "",
9 | "messagingSenderId": ""
10 | }
11 |
12 | firebase = pyrebase.initialize_app(config)
13 |
14 | storage = firebase.storage()
15 |
16 | from flask import *
17 |
18 | app = Flask(__name__)
19 |
20 | @app.route('/', methods=['GET', 'POST'])
21 | def basic():
22 | if request.method == 'POST':
23 | upload = request.files['upload']
24 | storage.child("images/new.mp4").put(upload)
25 | return redirect(url_for('uploads'))
26 | return render_template('index.html')
27 |
28 |
29 | @app.route('/uploads', methods=['GET', 'POST'])
30 | def uploads():
31 | if request.method == 'POST':
32 | return redirect(url_for('basic'))
33 | if True:
34 | links = storage.child('images/new.mp4').get_url(None)
35 | return render_template('upload.html', l=links)
36 | return render_template('upload.html')
37 |
38 | if __name__ == '__main__':
39 | app.run(debug=True)
40 |
--------------------------------------------------------------------------------
/Storage/example.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kanuarj/FirebasePython/25f902ec5b5ed305a97e24e612ae652770f4d07e/Storage/example.jpg
--------------------------------------------------------------------------------
/Storage/image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kanuarj/FirebasePython/25f902ec5b5ed305a97e24e612ae652770f4d07e/Storage/image.jpg
--------------------------------------------------------------------------------
/Storage/static/cover.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Globals
3 | */
4 |
5 | /* Links */
6 | a,
7 | a:focus,
8 | a:hover {
9 | color: #fff;
10 | }
11 |
12 | /* Custom default button */
13 | .btn-secondary,
14 | .btn-secondary:hover,
15 | .btn-secondary:focus {
16 | color: #333;
17 | text-shadow: none;
18 | /* Prevent inheritance from `body` */
19 | background-color: #fff;
20 | border: .05rem solid #fff;
21 | }
22 |
23 |
24 | /*
25 | * Base structure
26 | */
27 |
28 | html,
29 | body {
30 | height: 100%;
31 | background-color: #333;
32 | }
33 |
34 | body {
35 | display: -ms-flexbox;
36 | display: flex;
37 | color: #fff;
38 | text-shadow: 0 .05rem .1rem rgba(0, 0, 0, .5);
39 | box-shadow: inset 0 0 5rem rgba(0, 0, 0, .5);
40 | }
41 |
42 | .cover-container {
43 | max-width: 42em;
44 | }
45 |
46 |
47 | /*
48 | * Header
49 | */
50 | .masthead {
51 | margin-bottom: 2rem;
52 | }
53 |
54 | .masthead-brand {
55 | margin-bottom: 0;
56 | }
57 |
58 | .nav-masthead .nav-link {
59 | padding: .25rem 0;
60 | font-weight: 700;
61 | color: rgba(255, 255, 255, .5);
62 | background-color: transparent;
63 | border-bottom: .25rem solid transparent;
64 | }
65 |
66 | .nav-masthead .nav-link:hover,
67 | .nav-masthead .nav-link:focus {
68 | border-bottom-color: rgba(255, 255, 255, .25);
69 | }
70 |
71 | .nav-masthead .nav-link+.nav-link {
72 | margin-left: 1rem;
73 | }
74 |
75 | .nav-masthead .active {
76 | color: #fff;
77 | border-bottom-color: #fff;
78 | }
79 |
80 | @media (min-width: 48em) {
81 | .masthead-brand {
82 | float: left;
83 | }
84 |
85 | .nav-masthead {
86 | float: right;
87 | }
88 | }
89 |
90 |
91 | /*
92 | * Cover
93 | */
94 | .cover {
95 | padding: 0 1.5rem;
96 | }
97 |
98 | .cover .btn-lg {
99 | padding: .75rem 1.25rem;
100 | font-weight: 700;
101 | }
102 |
103 |
104 | /*
105 | * Footer
106 | */
107 | .mastfoot {
108 | color: rgba(255, 255, 255, .5);
109 | }
110 |
111 | .random {
112 | color: rgba(255, 255, 255, .5);
113 | }
--------------------------------------------------------------------------------
/Storage/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
9 |
11 |
13 |
15 |
16 | Document
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/Storage/templates/upload.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
10 |
12 |
14 |
16 |
17 |
18 |
19 |
20 |
22 |
23 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------