Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Running the Flask App Locally

  1. Install Python

    • Ensure you have Python 3.9+ installed. You can check using:
      python --version
  2. Create a Virtual Environment

    • Navigate to the project directory and run:
      python -m venv venv
      source venv/bin/activate  # On Windows use: venv\Scripts\activate
  3. Install Dependencies

    • Install required packages using:
      pip install -r requirements.txt
  4. Set Up Environment Variables

    • Ensure you have a .env file in the project root with:
      MY_ENV_VAR=HelloWorld
      
  5. Run the Flask App

    • Start the application:
      python app.py
    • The app should now be running at http://127.0.0.1:5000/.
  6. Test API Endpoints Using Postman

    • GET request:
      • URL: http://127.0.0.1:5000/get
      • Response should contain message and env_value.
    • POST request:
      • URL: http://127.0.0.1:5000/post
      • Body (JSON):
        {
          "key": "value"
        }
      • Response should contain received_data.

Running the App Using Docker for CI/CD

  1. Build the Docker Image

    docker build -t flask-app .
  2. Run the Container

    docker run -p 5000:5000 --env-file .env flask-app
  3. Test API Endpoints

    • Use Postman with the same URLs as above (http://127.0.0.1:5000/get and http://127.0.0.1:5000/post).
  4. Pushing to a Container Registry (Optional)

    • Tag and push the image to a registry (e.g., Docker Hub, AWS ECR):
      docker tag flask-app username/flask-app:latest
      docker push username/flask-app:latest
    • Replace username with your actual Docker Hub or registry username.
  5. Deployment in CI/CD

    • Modify your CI/CD pipeline to pull the image and deploy it to a server or container orchestration platform like Kubernetes or AWS ECS.

This guide provides the necessary steps to run and test the application locally and explains how to prepare it for deployment using Docker.

About

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages