Im trying to allow users to upload images to my firebase storage database this way:
import pyrebase
from flask import *
app = Flask(__name__)
config = {
#Hidden
}
firebase = pyrebase.initialize_app(config)
storage = firebase.storage()
auth = firebase.auth()
@app.route('/', methods=['GET', 'POST'])
#Login
def basic():
unsuccessful = 'Please check your credentials'
successful = 'Login successful'
if request.method == 'POST':
email = request.form['name']
password = request.form['pass']
try:
auth.sign_in_with_email_and_password(email, password)
return render_template('index.html', s=successful)
except:
return render_template('new.html', us=unsuccessful)
return render_template('new.html')
#Posting function
@app.route('/', methods=['GET','POST'])
def newProduct():
if request.method == 'POST':
try:
path_on_cloud = "images/newproduct.jpg"
path_local=request.form['file']
storage.child(path_on_cloud).put(path_local)
return render_template("index.html")
except:
return render_template("index.html")
The basic function which allows the users to log in works without any issues. However i get the following 404 error when trying to upload a picture to the firebase storage database: "Not Found The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again."
i have two html files: new.html which contains the log in, and index.html which is the page that follows where the upload of an image is done.
I hope one of you can see what i've done wrong or what im missing. Thanks in advance!