#!/usr/bin/python
# -*- coding: utf-8 -*-

import cgi, cgitb, os, sys, time, subprocess

cgitb.enable()

form = cgi.FieldStorage()
action = form['action'].value

print "Content-type:text/html\r\n\r\n"

if action == "1":
    os.system("echo 1 > /var/tmp/wui_actions")
    print("Defaults Restored Successfully")

elif action == "2":
    os.system("echo 2 > /var/tmp/wui_actions")
    print("Resetting Codec")

elif action == "3":
    os.system("echo 3 > /var/tmp/wui_actions")
    print("Rebooting Unit")

else:
    print("Invalid Action")
	