Home > Net >  From flask-login import breaks deployment of test app in google app engine
From flask-login import breaks deployment of test app in google app engine

Time:01-24

I'm a real beginner and I need to better myself.

Running a test app in Google app engine, via google cloud platform using cloud shell editor and terminal yields a nice static test website. Everything works fine, but when I add the following little code to the main.py file and deploy:

from flask_login import LoginManager

then the site crashes I think i.e. the site displays:

502 Bad Gateway


  nginx

This was unexpected because the following code is on the main.py file when it is working fine:

from flask import Flask, redirect, request, url_for, render_template

Why does from flask work fine, but from flask-login does not?

Since I'm a real beginner I thought I had to change the requirements.txt file, but, if it is not used anyways in app engine deployment, just in local testing.

CodePudding user response:

The requirements.txt is used by the App Engine. It specifies the list of dependencies, that are used in the application. Locally and also during the App Engine Deployment. App Engine cannot guess otherwise, which dependencies it should install.

So you need to add Flask-Login (https://pypi.org/project/Flask-Login/) to the requirements.txt (with or without version), and then you can import the library in your application.

CodePudding user response:

Python 2 Apps don't use requirements.txt file. For Python 2 Apps, you upload your lib folder (where you've installed all of your requirements) as part of your deployment process.

Python 3 Apps use requirements.txt file. Unlike Python 2 Apps, your library or virtual env shouldn't be deployed (uploaded to Production during deployment). To run your App, Google App Engine reads the contents of your requirements.txt file, installs it and then runs your App. This means the file must contain the list of all external libraries needed to run your App

  • Related