Skip to content

About

A Simple Weight Record demo, using json format to store data.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weight Tracker

A lightweight personal weight logging app with a FastAPI backend and a plain-HTML/JS frontend. Records are stored in a local JSON file — no database setup required.

It maybe combined with esp32 later.


Features

  • Log weight entries with date and time (auto-filled to now if left blank)
  • View all records in a searchable table with high/low badges
  • Summary stats: latest, highest, and lowest weight at a glance
  • Delete any entry by index
  • Single-file frontend served directly by the API server

Project Structure

.
├── server.py          # FastAPI app — REST API + static file serving
├── main.py            # Standalone CLI helper for reading/writing records
├── index.html         # Frontend UI (served at http://localhost:8000)
├── data.json          # Persistent record store (auto-created on first write)
└── requirements.txt   # Python dependencies

Requirements

  • Python 3.8+
  • pip

Installation

pip install -r requirements.txt

Running the Server

uvicorn server:app --reload

Then open http://localhost:8000 in your browser.

The API documentation (auto-generated by FastAPI) is available at http://localhost:8000/docs.


API Reference

Method Endpoint Description
GET /records Return all weight records
POST /records Add a new record
DELETE /records/{index} Delete a record by its index

POST /records — Request Body

{
  "date": "17.05.2025",
  "time": "08:30",
  "weight": 75.5
}
  • date — format dd.mm.yyyy; leave empty ("") to use today's date
  • time — format hh:mm; leave empty ("") to use the current time
  • weight — positive number (in kg)

Data Format

Records are stored in data.json as a plain JSON array:

[
  {
    "date": "17.05.2025",
    "time": "08:30",
    "weight": 75.5
  }
]

You can edit this file directly if needed.


CLI Usage (main.py)

main.py provides a simple command-line interface for adding records without starting the server:

python main.py

It will print all existing records, then prompt you to enter a new weight.


Notes

  • CORS is open (allow_origins=["*"]), which is fine for local use. Restrict this before any public deployment.
  • There is no authentication. This app is intended for personal, local use only.
  • Deleting a record shifts the indices of all subsequent records, so always fetch the current list before deleting by index.

About

A Simple Weight Record demo, using json format to store data.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages