I'm trying this tutorial: https://towardsdatascience.com/sample-load-balancing-solution-with-docker-and-nginx-cf1ffc60e644
GitLab repo here: https://gitlab.com/ouassini/load-balancing
When I manually test both Flask app1.py and/or app2.py they both load on port 5000:
ubuntu@docker:~/GitLab-Repos/load-balancing/app1$ python3 app1.py
* Serving Flask app 'app1'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5000
* Running on http://192.168.64.5:5000
Press CTRL+C to quit
* Restarting with stat
* Debugger is active!
* Debugger PIN: 900-505-536
However, when I try and run the docker container both App1 and App2 crash immediately and Nginx shows https://localhost:8080 as 502 Bad Gateway nginx/1.23.2:
2022-11-25 14:10:29 Traceback (most recent call last):
2022-11-25 14:10:29 File "//app1.py", line 1, in <module>
2022-11-25 14:10:29 from flask import request, Flask
2022-11-25 14:10:29 File "/usr/local/lib/python3.11/site-packages/flask/__init__.py", line 14, in <module>
2022-11-25 14:10:29 from jinja2 import escape
2022-11-25 14:10:29 ImportError: cannot import name 'escape' from 'jinja2' (/usr/local/lib/python3.11/site-packages/jinja2/__init__.py)
I found this SO post which seems to address the issue: ImportError: cannot import name 'escape' from 'jinja2'
However, after updating the requirements.txt file to use Flask==2.1.0
the issue still persists.