Python code to pull recent status messages from status.lol and generate javascript that can be embedded
Find a file
mihobu 2662ca9bb8 Update README.md
Added instructions for making a Requests Lambda Layer
2026-04-25 12:24:46 +00:00
lambda_function.py Add lambda_function.py 2026-04-25 11:51:10 +00:00
README.md Update README.md 2026-04-25 12:24:46 +00:00

statuslog-to-javascript

Python code to pull recent status messages from status.lol and generate javascript that can be embedded

Prerequisite

  1. A Lambda Layer that includes the Python Requests package, which is not natively available in Lamdba.

(Rough) Instructions for Use

  1. Create Lambda Function and insert code (lambda_handler.py)
  2. Update OMGLOL_USERNAME in lambda_handler() function
  3. Add Requests Lambda Layer to Lambda Function
  4. Configure Lambda Function a. Increase maximum runtime from the default 3 seconds (I have mine set to 12 seconds) b. Make sure the Function URL is enabled and public; configure to accept GET requests only.

Usage

Embed the following in your HTML (e.g. on your /now page):

<script src="https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.lambda-url.us-east-2.on.aws/?days=10&statuses=20"></script>

The following parameters are allowed (in order of precedence):

  1. hours=HOURS Return statuses for the last HOURS hours
  2. days=DAYS Return statuses for the last DAYS days
  3. weeks=WEEKS Return statuses for the last WEEKS weeks (computed as DAYS = WEEKS × 7)
  4. months=MONTHS Return statuses for the last MONTHS months (computed as DAYS = MONTHS × 30.4)
  5. years=YEARS Return statuses for the last YEARS years (computed as DAYS = YEARS × 365.25)

You can also specify a maximum number of statuses to return:

  1. statuses=MAX (default=1)

How to Create the Requests Lambda Layer

Im doing this on a Mac running Tahoe 26.3.1 (a).

  1. Create a Python environment for your target version. (Im using Anaconda distro.)
conda create -n python_3_13 python=3.13
  1. Activate the new envirnment
conda activate python_3_13
  1. Create a working directory. Make sure the version number matches.
mkdir -p requests-layer/python/lib/python3.13/site-packages
  1. Install packages to the target directory. This will install non-binary versions of the Requests package, as well as several dependencies.
pip install requests --target requests-layer/python/lib/python3.13/site-packages --no-binary=:all:
  1. Package the contents into a ZIP file. Note the change directory in the first step. This ensures that the python directory is the first one in the path. Thats important for the Lambda Layer to work correctly. I also like to include a version number that matches the Layer version.
cd requests-layer
zip -r ../requests-layer-v3.zip ./python

Now youre all set to create your Lambda Layer and add it to your Lambda Function(s).