Skip to content

Instantly share code, notes, and snippets.

@RichardBronosky
Created February 19, 2018 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RichardBronosky/dd10a07de95a888b63964fe5b548b672 to your computer and use it in GitHub Desktop.
Save RichardBronosky/dd10a07de95a888b63964fe5b548b672 to your computer and use it in GitHub Desktop.
A Python cgi demo
echo -e "\n\n Usage: after running this script, visit http://localhost:8000/cgi-bin/hello \n\n"
mkdir /tmp/cgi-bin/
cat > /tmp/cgi-bin/hello <<EOF
#!/bin/bash
echo -e "Content-Type: text/plain\n\n"; date; echo; env
EOF
chmod +x /tmp/cgi-bin/hello
(cd /tmp; python3 -m http.server --cgi 8000)
@RichardBronosky
Copy link
Author

This can be used to blink an LED on an RPi if you put https://gist.github.com/RichardBronosky/b037de3e8763887b034298057200bd02 in your /tmp/cgi-bin folder and https://gist.github.com/RichardBronosky/7f5832b2e0bac20db386bef4a7962a99 in /home/pi/ (or edit the path of DAEMON= on line 8 of the daemon example)

The LED pins are defined in DAEMON_ARGS= on line 9 of the daemon example. The meaning of that argument is explained in the pi_gpio_hack example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment