Skip to content

ajbharani/simple-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask Welcome App

A simple Flask application that displays a welcome message on the landing page. This app can be run locally with Python or containerized with Docker.

Features

  • Simple Flask web application with a welcome page
  • Responsive HTML design with CSS styling
  • Multiple deployment options (local, Docker)

Prerequisites

  • Python 3.8+ (for local development)
  • Docker (for containerized deployment)

Local Development

Option 1: Run with Python directly

  1. Install dependencies:
pip install -r requirements.txt
  1. Run the application:
python app.py
  1. Open your browser and navigate to http://localhost:8080

Docker Deployment

Build and run the Docker container:

  1. Build the Docker image:
docker build -t flask-welcome-app .
  1. Run the container:
docker run -d -p 8080:8080 --name flask-app flask-welcome-app
  1. Access the application at http://localhost:8080

Docker management commands:

  • Stop the container: docker stop flask-app
  • Remove the container: docker rm flask-app
  • View logs: docker logs flask-app

Shut down and clean up after testing:

  1. Stop and remove the container:
docker stop flask-app
docker rm flask-app
  1. Remove the Docker image (optional):
docker rmi flask-welcome-app
  1. Or do it all in one command:
docker stop flask-app && docker rm flask-app && docker rmi flask-welcome-app

Project Structure

.
├── app.py                 # Main Flask application
├── requirements.txt       # Python dependencies
├── Dockerfile            # Docker configuration
├── .dockerignore         # Docker ignore file
└── README.md            # This file

Configuration

Environment Variables

The application uses the following default configuration:

  • Host: 0.0.0.0 (all interfaces)
  • Port: 8080
  • Debug: True (local), False (production)

Customization

Modify the Welcome Message

Edit the HTML content in the welcome() function in app.py to customize the welcome message and styling.

Add New Routes

Add new routes to app.py:

@app.route('/about')
def about():
    return '<h1>About Page</h1>'

Environment-Specific Configuration

For different environments, consider using environment variables:

import os

app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', 'False').lower() == 'true'

Troubleshooting

Local Issues

  • Ensure Python 3.8+ is installed
  • Check if port 8080 is available
  • Verify all dependencies are installed

Docker Issues

  • Ensure Docker is running
  • Check if port 8080 is available on host
  • View container logs: docker logs flask-app

Production Considerations

  • Use environment variables for configuration
  • Implement proper logging
  • Add health check endpoints
  • Use HTTPS with SSL certificates
  • Implement proper error handling
  • Add monitoring and alerting
  • Use a proper database for data persistence
  • Implement CI/CD pipeline for deployments

License

This project is open source and available under the MIT License.

About

Simple app to verify Cloud Formation setup

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published