From 7d8ca2b71a28cac4d636978c0136dad2b631172f Mon Sep 17 00:00:00 2001 From: mattx Date: Sun, 6 Sep 2020 20:22:49 +0000 Subject: [PATCH] add a horrible OS detector --- distro.py | 13 +++++++++++++ index.md | 1 + 2 files changed, 14 insertions(+) create mode 100755 distro.py diff --git a/distro.py b/distro.py new file mode 100755 index 0000000..53cf764 --- /dev/null +++ b/distro.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +import os +import re +print("Content-Type: text/html; charset=utf-8") +print() +print("Distro detect") +ua = os.environ["HTTP_USER_AGENT"] +if ua.startswith("Mozilla/5.0"): + info = re.findall(r"\((.*?)\)", ua) + distro = info[0].split("; ")[1] + print("

You are using " + distro + "

") +else: + print("This only works with Firefox") diff --git a/index.md b/index.md index ae28c17..577a0c8 100644 --- a/index.md +++ b/index.md @@ -10,3 +10,4 @@ welcome to my site, it's pretty empty as you can see at the moment - [about this](about.html) - [a frogcat! use with curl](frogcat) - [image formats a friend made for a minecraft computer mod](sifarchive) +- [Horrible OS detection script](distro.py)