Skip to content

XueqingWu/individual_4_xueqing_wu

Repository files navigation

CI

Auto Scaling Flask App Using Azure As a Service

Illness to Nutrition Web Service Link

Youtube Video

Purpose

The goal of this project is to build a publicly accessible auto-scaling container using Azure App Services and Flask. This is an easy way to build and deploy a scaleable web-hosted.

Overview of the Service

This service take the input of an illness that useres give and return the nutrient they need for their body. It is a Flask web application integrated with OpenAI's LLM model, utilizing Docker for effective containerization.

Workflows:

  1. User Input: Users input illness into the application.
  2. Search: The application processes the inputted illness and searches for nutrients needed for this illness.
  3. Output: The nutrients needed for this illness is listed.

Take Input:

Screen Shot 2023-12-10 at 1 21 18 AM

Return Outputs:

Screen Shot 2023-12-10 at 1 21 27 AM

Key Components

  1. Flask Web Application:
    • Functionality: The web app allows users to input prompts, which are then processed by the GPT-3.5 model to generate responses. The responses are displayed on a results page.
      • The web app (main.py) incorporates routes for the index page and the result page. User can input illness.
      • HTML Templates: The project contains HTML templates (index.html and result.html) providing a user-friendly interface.
  2. Open AI LLM Model Integration:
    • API Interaction: The application interfaces with the Open AI LLM Model via API calls. It sends a the user input of nutrients to get predictions.
  3. Docker Containerization: Dockerfile:
    • This Dockerfile containerizes a Flask app, setting up a Docker container with Python and Gunicorn to run the web application. It encapsulates the app's code and dependencies, simplifying deployment across different environments.

Azure Container Apps Deployment

Azure has its own docker. The web service is deployed on Azure

  • Azure Container Registry:
Azure Container Registry
  • Azure Container Apps Deployment:
Azure Container Apps Deployment
  • Azure Docker Image:
Docker Image

Preparation

  1. git clone the repo
  2. install: make install
  3. get access to user token via GPT
  4. create an env file and add user token
  5. run: python main.py and navigate to the locally hosted website
  6. upload image or use default image
  7. build docker image: docker build --tag <insert image name> .
  8. login to azure cli: az login
  9. deploy azuer web app: az containerapp up --resource-group <insert resource group> --name <insert app name> --ingress external --target-port 50505 --source .
  10. view app via conatiner apps and docker image via container regsitry in azure web portal

Check Format and Test Errors:

  1. Format code make format
  2. Lint code make lint
  3. Test coce make test

References

  1. https://github.com/nogibjj/python-ruff-template
  2. https://learn.microsoft.com/en-us/azure/developer/python/tutorial-containerize-simple-web-app?tabs=web-app-flask
  3. https://learn.microsoft.com/en-us/azure/container-apps/scale-app?pivots=azure-cli
  4. https://github.com/Azure-Samples/msdocs-python-flask-webapp-quickstart

About

Build an openai api to get the nutritions needed for certain illness

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published