Sign inSign up

maze88/todo

By maze88

Updated over 3 years ago

Simple task list mock application with integration to MongoDB.

Image
0

131

maze88/todo repository overview

Simple To-Do List Application

This is a simple web application that allows users to manage tasks on a to-do list. It also exposes a REST API for programmatic access, as well as metrics via a /metrics endpoint.

Building the Application

To build the application:

docker build -t todo:latest .

Configuration

To configure the application, adjust the following environemnt variables:

Variable nameDefault valueDescription
MONGO_URI"mongodb://localhost:27017/"The URI of your MongoDB database.
LOG_LEVEL"INFO"The desired logging level (DEBUG, INFO, WARNING, ERROR, or CRITICAL).
METRICS_ENABLED"true"If metrics should be registered (note that the /metrics route still will exist, just won't contain any data).
DEBUG_ENABLED"false"If the Flask server should be started in Debug mode.

Running the Application

To run the application, start a Docker container using the todo-app image:

docker run -p 5000:5000 -e MONGO_URI=<mongo_uri> todo:latest

By default, the application listens on port 5000, so you can access it by visiting http://localhost:5000 in your web browser.

Usage

Web UI

The web UI provides a simple interface for managing tasks on the to-do list. You can add tasks by typing them into the input box and clicking "Add Task" and delete tasks by clicking the "Delete" button next to the task you want to remove.

REST API

The REST API provides programmatic access to the to-do list, and adds the additional functionality of editing existing tasks. You can interact with it using standard HTTP methods (GET, POST, PUT):

  • To retrieve a list of all tasks, make a GET request to /api.
  • To add a task, make a POST request to /api/add with the task in the form data.
  • To delete a task, make a POST request to /api/delete.
  • To edit a task, make a PUT request to /api/edit with both the old & new and tasks in the form data.

Example API test call (with curl):

curl -X PUT localhost:5000/api/edit -d "old_task=make cake&new_task=chop salad"

Metrics

The application exposes metrics via the /metrics endpoint. If metrics are enabled (METRICS_ENABLED=true), you can access them by visiting http://localhost:5000/metrics in your web browser.

The following metrics are available:

Metric nameTypeDescription
index_requestsCounterCount of requests to index.html page.
tasks_countGuageNumber of tasks in the database.
tasks_addedCounterCount of tasks added since the application started.
tasks_editedCounterCount of tasks edited since the application started.
tasks_deletedCounterCount of tasks deleted since the application started.

Tag summary

Content type

Image

Digest

sha256:6b743b85c

Size

52.1 MB

Last updated

over 3 years ago

docker pull maze88/todo