Important
The project state is alfa [unstable]! Many things could change and there are a lot of moving parts ;)
- Flasky Goodness: Our backend’s running on Flask, the web framework for cool cats.
- JSON Jive: Store your fuel data in a slick JSON file.
- Responsive Vibes: Looks great on both your massive desktop and your tiny phone.
- MPG Magic: Calculate fuel economy and total fuel cost with ease.
- CSV Shuffle: Import/export your data like a pro.
- Backup Buddy: Automatic backup before any major moves.
- Tests & Tunes: Some unit tests to keep things in check.
- Docker Delight: Option to run in Docker for ultimate container coolness.
Edit and delete entries with style. Confirm deletions (because we're cautious like that). Restore data from the last backup with a click. Responsive table with checkboxes for easy selection. Export and import data to/from CSV. Main page shows the input form and your fuel data table in all its glory.
fuel_log_webapp/
├── fuel_tracker/
│ ├── __init__.py
│ ├── app.py
│ ├── templates/
│ │ ├── index.html
│ │ └── login.html
│ ├── static/
│ │ └── style.css
│ └── data.json
├── tests/
│ └── test_app.py
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
└── README.md
- Install virtualenv (if not already installed):
pip install virtualenv
- Create a Virtual Environment:
cd /path/to/your/project virtualenv venv
- Activate the Virtual Environment:
source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Run the Flask app:
python /fuel_tracker/app.py
- Run the unit tests:
python -m unittest discover -s tests
Once you’re done working in the virtual environment, you can deactivate it: deactivate
Distance Traveled (miles)Fuel Used (gallons)MPG=Fuel Used (gallons from liters)Distance Traveled (miles) The MPG is calculated as the distance traveled divided by the amount of fuel used in gallons. Here's the formula:
Odometer reading difference = 1000 - 900 = 100 miles
Fuel used = 40 liters, which needs to be converted to gallons (1 liter ≈ 0.264172 gallons).
Fuel Used (gallons)=40×0.264172=10.56688Fuel Used (gallons)=40×0.264172=10.56688
MPG=10010.56688≈9.4635MPG=10.56688100≈9.4635
The value 9.4635 is accurate, updated the test case to match this calculation.
docker build -t fuel_tracker_app .
docker run -p 5000:5000 fuel_tracker_app
docker-compose up --build