Redirect with arguments

21 views
Skip to first unread message

Lars Staun Knudsen

unread,
Apr 26, 2015, 7:23:19 AM4/26/15
to we...@googlegroups.com
Hi

I'm trying to make a simple webfrontend to manage a AV receiver via telnet. The AVController class contains the telnet communication and lists of devices and telnet commands. When i send a command from Index to /send, i want the telnet reply and the command returned. But im not getting anything returned in $status and $selected parses the url and add /send to the variable every time i click, "send/send/send/send/send/send/send/send/SndOn". How to return the reply and still  keep the "pretty url"? Or is there a better way.

/Lars
--------------------------------
import web
from av_telnet import AVController

av = AVController()
render = web.template.render('templates/')
urls = (
    '/(.*)', 'index',
    '/read','read_output',
    '/send/(.*)','send_cmd',
    '/select/(.*)','select_device'
    )

class index:
    def GET(self,selected=None,status=None):
        av_list = av.get_commandnames()
        dev_list = av.get_devicenames()
        return render.index(av_list,dev_list,selected,status)

class send_cmd:
    def GET(self, cmd):
        s = "test"
        resplay = av.send(cmd)
        web.redirect('/',cmd,reply)

class select_device:
    def GET(self, dev):
        return "Select dev: {0}".format(dev)

----------- Simple test index.html --------------
$def with (cmds,devs,selected,status)

Select: $selected
Status: $status
<br>
$for item in cmds:
    <a href="send/$item">$item</a><br>

<br>
$for item in devs:
    <a href="select/$item">$item</a><br>
Reply all
Reply to author
Forward
0 new messages