This is the source code for the Python Django application seizures.ericoc.com
.
While the website itself is for authorized users only, there are a few example screenshots below!
This is also an ongoing personal project - which originally began as a small Python Flask application - to further my web development skills, while also trying my best to track my epileptic seizures accurately!
I use an Apple Shortcut to track when, and where, I have epileptic seizures! The Apple Shortcut can be executed from my Apple Watch, iPad, iPhone, or Mac with just two (2) taps. Less detailed events can also be added from a browser. The Apple Watch shortcut could even theoretically be used by another person, while the watch remains on my wrist.
Seizures are generally displayed three (3) different ways - map, chart, or table - shown below.
The default page, after logging in, is a map of seizures displayed using Leaflet, in combination with OpenStreetMap.
Seizure frequency, per day, is charted with Highcharts.
Detailed information about each seizure can be listed using
DataTables which supports copying rows to the
clipboard, as well as exporting comma-separated values (.csv
) and
Microsoft Excel (.xlsx
) files.
The website depends upon nginx, gunicorn, Python 3.13, Django, Django REST framework, and relies upon a local PostgreSQL database, as well as Django QuerySets to a Snowflake database - where seizure event data is stored - using django-snowflake.
Seizures are stored in a Snowflake database (schema), while all other Django data including users/permissions are stored locally in PostgreSQL.
An HTTPS REST API is available with Django REST framework (DRF). Seizures are
added by HTTPS POST requests to the /api/seizures/
DRF end-point, from the
Apple Shortcut.
When the Apple Shortcut (Add_Seizure.shortcut) is
executed, the Apple device sends an HTTPS JSON POST request to the
/api/seizures/
Django REST framework end-point using token-based
authentication in an Authorization
header, subsequently writing a row to the
Snowflake database - a "seizure" - including the following data, at the time
of the event.
-
Timestamp
- Coordinated Universal Time (UTC)
-
Device Name
-
Device Type
iPhone
Mac
Watch
iPad
-
Battery
0
-100
-
Brightness
0
-1
-
Volume
0
-1
-
Latitude
-
Longitude
-
Address
- According to Apple.
-
SSID
- Not sent by Apple Watch.
-
Altitude
- Measured in meters.
- Not sent by MacBook.