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.
- 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.
Before you begin, ensure you have the following installed:
There are two ways to run this application: using the pre-built image from Docker Hub or building it from the source code.
This is the quickest way to get the application up and running.
-
Pull the image from Docker Hub:
docker pull karahub/python-web-app:latest
-
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
-
View the application: Open your web browser and navigate to http://localhost:5000. You should see the message "Hello 🙋♂️, World from Docker!".
Use this method if you have cloned the repository and want to build the image yourself.
-
Clone the repository:
git clone https://github.com/karadhub/python-web-app.git cd python-web-app -
Build the Docker image:
docker build -t python-web-app . -
Run the container:
docker run -d -p 5000:5000 python-web-app
-
View the application: Open your web browser and navigate to http://localhost:5000.
To run the application on your local machine for development:
-
Set up a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the app:
python app/main.py
-
The application will be running on http://localhost:5000.
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
- Default: