简体   繁体   中英

How can I use my firebase credentials in a Flask application that I want to deploy in a AWS elastic beanstalk?

Inside my .zip source boudle I have:

  • templates/
  • application.py
  • serviceKey.json
  • requirements.txt

It runs locally in my machine with the following code, but when I deploy it in AWS elastic beanstalk it doesn't work.

from flask import Flask, request, jsonify, render_template
import firebase_admin
from firebase_admin import credentials, db

application = app = Flask(__name__)

cred = credentials.Certificate('./serviceKey.json') 
default_app = firebase_admin.initialize_app(cred, {"databaseURL": "<URL_to_my_firebasedb>"})

Ok my code was right, my problem had something to do with an invalid requirements.txt error that says: requirements.txt returned non-zero exit status 1.

My solution of my problem was to create other .zip source boundle that does not include the requirements.txt but the venv foler that I had in my local computer.

So the new .zip source boudle looks like this:

  • templates/
  • venv/
  • application.py
  • serviceKey.json

I get it from this answer. https://stackoverflow.com/a/43967554/13450998

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM