I am creating an NLP Flask app with Python and when I run the app in my IDE, everything works great and my app functions as expected.
I have an App Service in my Azure account that I am using for CI/CD deployment. The deployment is marked successful, however when I go to the app URL, I get the :( application error warning messing. I am very confused as to why this is happening.
Details:
Directory Structure:
MSDS498_ChatBot_FlaskApp/
├── app.py
├── img_etl.py
├── Makefile
├── README.md
├── requirements.txt
├── static
│ ├── brucechou1983_CheXNet_Keras_0.3.0_weights.h5
│ ├── Encoder_Decoder_global_attention.h5
│ ├── tokenizer.pkl
│ └── uploads
│ └── __init__.py
└── templates
├── acknowledgement.html
├── gen_text.html
├── home.html
├── output.html
├── upload.html
└── upload_img_rest.html
- Main Flask app is called
app
in the app.py
file. This is in the root folder of my directory which should get uploaded to the virtual machine. From the Microsoft documentation here the naming conventions are correct and App Service should find my app.py
file with no issues and launch the gunicorn WSGI server without issues... First 20 lines from the app.py
file shown below.
"""Main Flask App for ChatBot."""
from fileinput import filename
import os
from flask import Flask, render_template, request, jsonify, send_from_directory
from werkzeug.utils import secure_filename
from img_etl import make_prediction
# Define upload folder path:
UPLOAD_FOLDER = os.path.join("static",'uploads')
# Define allowed files:
ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'}
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
@app.route("/")
def welcome():
"""Chatbot API Home Page."""
return render_template("home.html")
I am unable to verify if the files are being written to the virtual machine. I am unable to SSH into the VM hosting my web app since it doesn't appear to be running.
I know there are some dependencies that are required outside of the requirements.txt
file and I have added them to the Github Actions CI/CD build file.... Ex:
- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: Make virtual environment compatible
run: |
sudo apt-get update
sudo apt-get install libgl1
- name: Install dependencies
run: pip install -r requirements.txt
Since the build step is complete, I am assuming that the VM environment should have all dependencies required to run these files as done similarly in my IDE when I launch my own virtual environment.
It doesn't appear my files are being transferred to the VM so I tried to transfer via FTP using FileZilla with no luck.
Not really sure where to go from here... I was able to successfully launch the web app with the same App Service resource before adding some NLP functionality. I can go back and find the files / dependencies causing the issues, but that still won't solve the issues I am having.
Please advise.