Thanks to visit codestin.com
Credit goes to github.com

Skip to content

karadHub/python-web-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python Web App with Docker

A simple "Hello World" web application built with Python and Flask, containerized using Docker. This project serves as a basic template for a containerized Python web service that can be easily deployed.

Features

  • Simple and lightweight Flask application.
  • Containerized with Docker for consistent environments and easy deployment.
  • Customizable greeting message via an environment variable.
  • Serves a favicon for a professional look in the browser.

Prerequisites

Before you begin, ensure you have the following installed:


Getting Started

There are two ways to run this application: using the pre-built image from Docker Hub or building it from the source code.

Option 1: Run with the Pre-built Docker Image (Recommended)

This is the quickest way to get the application up and running.

  1. Pull the image from Docker Hub:

    docker pull karahub/python-web-app:latest
  2. Run the container: This command starts the container in detached mode and maps port 8080 on your machine to port 5000 in the container.

    docker run -d -p 5000:5000   karahub/python-web-app:latest
  3. View the application: Open your web browser and navigate to http://localhost:5000. You should see the message "Hello 🙋‍♂️, World from Docker!".

Option 2: Build and Run from Source Code

Use this method if you have cloned the repository and want to build the image yourself.

  1. Clone the repository:

    git clone https://github.com/karadhub/python-web-app.git
    cd python-web-app
  2. Build the Docker image:

    docker build -t python-web-app .
  3. Run the container:

    docker run -d -p 5000:5000 python-web-app
  4. View the application: Open your web browser and navigate to http://localhost:5000.


Local Development (Without Docker)

To run the application on your local machine for development:

  1. Set up a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  2. Install dependencies:

    pip install -r requirements.txt
  3. Run the app:

    python app/main.py
  4. The application will be running on http://localhost:5000.


Configuration

The application's greeting can be customized using an environment variable.

  • NAME: Sets the name displayed in the greeting message.
    • Default: Vaibhav
    • Example (Docker): docker run -e NAME="Universe" ...
    • Example (Local): NAME="Universe" python app/main.py

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •