Skip to main content

A web-based dashboard for managing and monitoring SMS messages, built with Flask and MySQL.

Project description

Gammu SMS Web Manager

A simple yet powerful Flask web application for managing SMS messages stored by Gammu in a MySQL database. This tool provides a modern, real-time web interface to view, manage, and receive notifications for incoming SMS.

Features

  • Modern UI: A clean, responsive user interface built with Tailwind CSS.
  • Real-Time Notifications: Get instant browser notifications when a new SMS arrives.
  • Live UI Updates: The message list updates automatically, without needing a page refresh.
  • Bulk Actions: Select multiple messages to mark as read or delete them all at once.
  • Easy Setup: Single-file application with minimal dependencies.
  • Custom Modals: A polished user experience with custom confirmation dialogs instead of native browser alerts.

Prerequisites

  • Python 3.13.1+
  • A GSM modem or mobile phone that can be connected to your server. (I used GPRS SIM800 Module)
  • A MySQL server.
  • Poetry For dependency management.
  • asdf (optional)

Part 1: Gammu Installation and Configuration

Before setting up the web app, you need to install and configure Gammu (smsdrc) to store SMS messages in your MySQL database.

1. Install Gammu and SMSD

On Debian-based Linux distributions (like Ubuntu or Raspberry Pi OS), you can install Gammu and the Gammu SMS Daemon (SMSD) using the package manager.

  sudo apt-get update  
  sudo apt-get install gammu gammu-smsd

2. Configure gammu-smsd to Connect to Your Modem

First, you need to configure Gammu to recognize your modem.

  • Connect your modem to the server. It will usually be available at a path like /dev/ttyUSB0 or /dev/ttyACM0.
  • Create /etc/gammu-smsdrc file like below:
  sudo nano /etc/gammu-smsdrc

This is an example of gammu-smsdrc config:

[gammu]
device = /dev/ttyUSB0
connection = at115200

[smsd]
service = mysql
driver = native_mysql
host = localhost
user = gammu_user
password = "<password>"
database = gammu_db
logfile = /var/log/gammu-smsd.log
loglevel = debug

3. Set Up the MySQL Database

The Gammu SMSD service needs a database to store messages.

  • Log in to your MySQL server and create a new database and user for Gammu.
  CREATE DATABASE gammu\_db;  
  CREATE USER 'gammu\_user'@'localhost' IDENTIFIED BY 'your\_secret\_password';  
  GRANT ALL PRIVILEGES ON gammu\_db.\* TO 'gammu\_user'@'localhost';  
  FLUSH PRIVILEGES;  
  EXIT;
  • Gammu comes with a SQL script to create the necessary tables. Find and import it into your new database. The path may vary, but it's often found here:
    # The path to mysql.sql might be different on your system.

      mysql \-u gammu\_user \-p gammu\_db \< /usr/share/doc/gammu/examples/sql/mysql.sql
    

Part 2: Web App Setup and Installation

Now that Gammu is configured, you can set up the web application to manage the messages.

1. Clone the Repository

git clone <your-repository-url>  
cd <your-repository-directory>

2. Install Dependencies

Use Poetry to install the required Python packages from the pyproject.toml file.
poetry install

3. Configure Environment Variables

Create a .env file to hold your database credentials. These must match the credentials you used for Gammu SMSD.
# You can create this from scratch or copy an example if one exists
nano .env

Add the following content to the .env file:

# .env file  
DB_HOST=localhost  
DB_USER=gammu_user  
DB_PASSWORD='your_secret_password'  
DB_NAME=gammu_db  
SECRET_KEY='A long random string for flask sessions'

Important: The SECRET_KEY is used by Flask to secure user sessions. For generating a long, random string use this command python -c "import secrets; print(secrets.token_hex(32))"

4. Running the Application

Development Mode

Once the setup is complete, you can run the Flask application:
poetry run python app.py You will see output in your terminal indicating that the server is running:
Starting Flask server...
Access the app at http://127.0.0.1:5000

Open your web browser and navigate to http://127.0.0.1:5000 to start using the SMS manager.

Production Mode

For production deployments, it is recommended to use a production-ready WSGI server like Gunicorn.

First, install Gunicorn (if not already installed):

poetry add gunicorn

Then, run the application with Gunicorn:

poetry run gunicorn app:app

You can adjust the number of worker processes and bind to a specific address/port as needed:

poetry run gunicorn -w 4 -b 0.0.0.0:5000 app:app

For best results, consider running Gunicorn behind a reverse proxy such as Nginx for improved security and performance.

Running with systemd and Gunicorn

To run the web application as a background service, you can create a systemd unit file for Gunicorn.

  1. Create a systemd service file (replace <your-user> and <your-repository-directory> as needed):

    sudo nano /etc/systemd/system/gammu-sms-web.service
    
  2. Add the following content:

    [Unit]
    Description=Gammu SMS Web Manager (Gunicorn)
    After=network.target
    
    [Service]
    User=<your-user>
    Group=www-data
    WorkingDirectory=/home/<your-user>/<your-repository-directory>
    Restart=on-failure
    Environment=POETRY_VIRTUALENVS_IN_PROJECT=true
    ExecStart=/usr/bin/poetry run gunicorn -w 4 -b 0.0.0.0:5000 app:app
    
    [Install]
    WantedBy=multi-user.target
    
  3. Reload systemd and start the service:

    sudo systemctl daemon-reload
    sudo systemctl start gammu-sms-web
    sudo systemctl enable gammu-sms-web
    
  4. Check the status:

sudo systemctl status gammu-sms-web

Your Flask app will now run as a service and restart automatically if it crashes or the server reboots.

License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sms_dashboard-0.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sms_dashboard-0.1.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file sms_dashboard-0.1.0.tar.gz.

File metadata

  • Download URL: sms_dashboard-0.1.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sms_dashboard-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8cf5f405d0c574be1f9b2c6c52d158339c531360628d1227dce538e6607d8d18
MD5 0d99fc299c26709d0f89d906811108cd
BLAKE2b-256 3bbb80db125ff686d9c4880e30fd1c62dd69bf98b81831557cf76bf4d94493b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for sms_dashboard-0.1.0.tar.gz:

Publisher: publish.yml on mohammad-ahmadi1/sms-dashboard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sms_dashboard-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sms_dashboard-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sms_dashboard-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a8ad67e797519f894549f5cc5fc4c47be33edbdb303b3973e924fe77c8e9e1b
MD5 e1d1470ab91fe24789a9cafef7da2394
BLAKE2b-256 d72c3fd6c4e57b209ec7cf518958ae49292e715e82b96fe0074748bce47aa9c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for sms_dashboard-0.1.0-py3-none-any.whl:

Publisher: publish.yml on mohammad-ahmadi1/sms-dashboard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page