site/distro.py

14 lines
377 B
Python
Executable File

#!/usr/bin/env python
import os
import re
print("Content-Type: text/html; charset=utf-8")
print()
print("<title>Distro detect</title>")
ua = os.environ["HTTP_USER_AGENT"]
if ua.startswith("Mozilla/5.0"):
info = re.findall(r"\((.*?)\)", ua)
distro = info[0].split("; ")[1]
print("<p>You are using " + distro + "</p>")
else:
print("This only works with Firefox")