|
| 1 | +# **Carbon Footprint Calculator** |
| 2 | + |
| 3 | +An interactive web application that calculates your annual carbon footprint based on your daily activities, including transportation, home energy use, dietary habits, and waste management. The goal is to raise environmental awareness and encourage sustainable living by providing personalized feedback and suggestions for reducing carbon emissions. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## **Table of Contents** |
| 8 | + |
| 9 | +- [Features](#features) |
| 10 | +- [Prerequisites](#prerequisites) |
| 11 | +- [Installation](#installation) |
| 12 | +- [Usage](#usage) |
| 13 | +- [Project Structure](#project-structure) |
| 14 | +- [Technologies Used](#technologies-used) |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## **Features** |
| 19 | + |
| 20 | +- **Transportation Emissions Calculation** |
| 21 | + - Calculates emissions from car travel, public transportation, and flights. |
| 22 | +- **Home Energy Use Analysis** |
| 23 | + - Accounts for electricity, natural gas, fuel oil, and propane usage. |
| 24 | +- **Dietary Impact Assessment** |
| 25 | + - Considers the carbon footprint of different diets: meat-heavy, average, vegetarian, and vegan. |
| 26 | +- **Waste and Recycling Evaluation** |
| 27 | + - Factors in recycling habits and their impact on emissions. |
| 28 | +- **User-Friendly Web Interface** |
| 29 | + - Interactive forms for data input and clear presentation of results. |
| 30 | +- **Personalized Suggestions** |
| 31 | + - Offers practical tips to reduce your carbon footprint based on your inputs. |
| 32 | +- **Responsive Design** |
| 33 | + - Accessible on various devices, including desktops, tablets, and mobile phones. |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## **Prerequisites** |
| 38 | + |
| 39 | +- **Python 3.7 or higher** |
| 40 | +- **pip package manager** |
| 41 | +- **Virtual Environment (optional but recommended)** |
| 42 | + |
| 43 | +--- |
| 44 | + |
| 45 | +## **Installation** |
| 46 | + |
| 47 | +Follow these steps to set up the project on your local machine. |
| 48 | + |
| 49 | +### **1. Clone the Repository** |
| 50 | + |
| 51 | +```bash |
| 52 | +git clone https://github.com/yourusername/carbon-footprint-calculator.git |
| 53 | +cd carbon-footprint-calculator |
| 54 | +``` |
| 55 | + |
| 56 | +### **2. Create a Virtual Environment** |
| 57 | + |
| 58 | +It's recommended to use a virtual environment to manage dependencies. |
| 59 | + |
| 60 | +```bash |
| 61 | +python -m venv venv |
| 62 | +``` |
| 63 | + |
| 64 | +Activate the virtual environment: |
| 65 | + |
| 66 | +- **Windows:** |
| 67 | + |
| 68 | + ```bash |
| 69 | + venv\Scripts\activate |
| 70 | + ``` |
| 71 | + |
| 72 | +- **macOS/Linux:** |
| 73 | + |
| 74 | + ```bash |
| 75 | + source venv/bin/activate |
| 76 | + ``` |
| 77 | + |
| 78 | +### **3. Upgrade pip** |
| 79 | + |
| 80 | +```bash |
| 81 | +pip install --upgrade pip |
| 82 | +``` |
| 83 | + |
| 84 | +### **4. Install Dependencies** |
| 85 | + |
| 86 | +```bash |
| 87 | +pip install -r requirements.txt |
| 88 | +``` |
| 89 | + |
| 90 | +Ensure that the installed packages match the versions specified in `requirements.txt`: |
| 91 | + |
| 92 | +``` |
| 93 | +Flask==2.3.2 |
| 94 | +Werkzeug==3.0.4 |
| 95 | +``` |
| 96 | + |
| 97 | +### **5. Run the Application** |
| 98 | + |
| 99 | +```bash |
| 100 | +python app.py |
| 101 | +``` |
| 102 | + |
| 103 | +The application will start running on `http://127.0.0.1:5000/`. |
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | +## **Usage** |
| 108 | + |
| 109 | +### **Access the Application** |
| 110 | + |
| 111 | +Open your web browser and navigate to `http://127.0.0.1:5000/`. |
| 112 | + |
| 113 | +### **Input Your Data** |
| 114 | + |
| 115 | +1. **Transportation Emissions** |
| 116 | + |
| 117 | + - Enter your average weekly miles driven by car. |
| 118 | + - Provide your car's fuel efficiency (mpg). |
| 119 | + - Input miles traveled by bus and train. |
| 120 | + - Specify the number of flights taken per year. |
| 121 | + |
| 122 | +2. **Home Energy Use** |
| 123 | + |
| 124 | + - Enter your average monthly electricity usage in kWh. |
| 125 | + - Provide natural gas, fuel oil, and propane usage if applicable. |
| 126 | + |
| 127 | +3. **Dietary Impact** |
| 128 | + |
| 129 | + - Select your diet type from the options provided. |
| 130 | + |
| 131 | +4. **Waste and Recycling** |
| 132 | + - Indicate whether you recycle paper, plastic, glass, and metal. |
| 133 | + |
| 134 | +### **Calculate and View Results** |
| 135 | + |
| 136 | +- Click the **Calculate** button to submit your data. |
| 137 | +- The results page will display: |
| 138 | + - A breakdown of your annual emissions by category. |
| 139 | + - Total annual emissions in pounds and metric tons of CO2. |
| 140 | + - Comparison with the national average. |
| 141 | + - Personalized suggestions to reduce your carbon footprint. |
| 142 | + |
| 143 | +### **Calculate Again** |
| 144 | + |
| 145 | +- Use the **Calculate Again** button to return to the input form and reassess with different data. |
| 146 | + |
| 147 | +--- |
| 148 | + |
| 149 | +## **Project Structure** |
| 150 | + |
| 151 | +``` |
| 152 | +carbon-footprint-calculator/ |
| 153 | +├── app.py |
| 154 | +├── requirements.txt |
| 155 | +├── templates/ |
| 156 | +│ ├── base.html |
| 157 | +│ ├── index.html |
| 158 | +│ └── results.html |
| 159 | +├── static/ |
| 160 | +│ ├── style.css |
| 161 | +├── README.md |
| 162 | +``` |
| 163 | + |
| 164 | +- **app.py**: The main Flask application file containing routes and logic. |
| 165 | +- **requirements.txt**: Lists the Python dependencies and their versions. |
| 166 | +- **templates/**: Contains HTML templates for rendering web pages. |
| 167 | + - **base.html**: The base template that includes common elements. |
| 168 | + - **index.html**: The home page with the input form. |
| 169 | + - **results.html**: Displays calculation results and suggestions. |
| 170 | +- **static/**: Stores static files like CSS and images. |
| 171 | + - **style.css**: Custom styles for the application. |
| 172 | + - **screenshots/**: Contains images used in the README. |
| 173 | +- **README.md**: Comprehensive guide and documentation for the project. |
| 174 | + |
| 175 | +--- |
| 176 | + |
| 177 | +## **Technologies Used** |
| 178 | + |
| 179 | +- **Programming Language**: Python 3 |
| 180 | +- **Web Framework**: Flask |
| 181 | +- **Frontend Libraries**: |
| 182 | + - **Bootstrap 5**: For responsive design and styling. |
| 183 | +- **HTML/CSS**: Web page structure and styles. |
| 184 | + |
| 185 | +### **Troubleshooting** |
| 186 | + |
| 187 | +#### **ImportError: cannot import name 'url_quote' from 'werkzeug.urls'** |
| 188 | + |
| 189 | +If you encounter the following error: |
| 190 | + |
| 191 | +``` |
| 192 | +ImportError: cannot import name 'url_quote' from 'werkzeug.urls' |
| 193 | +``` |
| 194 | + |
| 195 | +This is due to a version incompatibility between Flask and Werkzeug. Ensure that you have compatible versions installed: |
| 196 | + |
| 197 | +- **Flask**: `2.3.2` or higher |
| 198 | +- **Werkzeug**: `3.0.4` or compatible with your Flask version |
| 199 | + |
| 200 | +#### **Steps to Resolve** |
| 201 | + |
| 202 | +1. **Update `requirements.txt`**: |
| 203 | + |
| 204 | + ``` |
| 205 | + Flask==2.3.2 |
| 206 | + Werkzeug==3.0.4 |
| 207 | + ``` |
| 208 | + |
| 209 | +2. **Reinstall Dependencies**: |
| 210 | + |
| 211 | + ```bash |
| 212 | + pip install -r requirements.txt |
| 213 | + ``` |
| 214 | + |
| 215 | +3. **Verify Installed Versions**: |
| 216 | + |
| 217 | + ```bash |
| 218 | + pip show Flask |
| 219 | + pip show Werkzeug |
| 220 | + ``` |
| 221 | + |
| 222 | +## **Contact** |
| 223 | + |
| 224 | +For any questions or suggestions, feel free to reach out: |
| 225 | + |
| 226 | +- **Email**: aswinpkumar03@gmail.com |
| 227 | +- **GitHub**: [AswinPKumar01](https://github.com/AswinPKumar01) |
| 228 | + |
| 229 | +--- |
| 230 | + |
| 231 | +Thank you for using the Carbon Footprint Calculator! Together, let's make a positive impact on the environment. |
0 commit comments