executing while loop and simultaneously redirecting to new page on form submission
Peter Tsapatsaris <[email protected]> Wed, 12 Oct 2016 20:30:53 -0700 (PDT)
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
Hello everyone,
I've been using cherrypy on a Raspberry Pi to run a web controllable LED
matrix. I've run into a bit of a wall. Short version of question: Is it
possible to send the user to a new webpage in a function WITHOUT returning
or breaking? I am trying to execute code in a block below the redirect.
Long version:
The LED control code executes on a while loop after receiving input from an
an HTML form like the following:
<form name="myform" class="rounded" action="ledDisplay" method="GET"
onsubmit="archive.html">
<input type="text" class="box" name="message" maxlength="1000"
placeholder="enter your message" />
<input type="submit">
</form>
The ledDisplay function executes the while loop with the message from the
form. My problem is this--after submission, I would like to redirect the
user to a new webpage (e..g, "thanks.html"). However, when I redirect it
either executes BEFORE the while loop, thus preventing the LED from
running, or executes AFTER the while loop, i.e., never.
Does anyone know if there is a way to get CherryPy to send the user to a
new webpage and then continue to execute a code block? Here is a skeleton
of the code I'm working with:
class myApp:
def index(self):
return open('index.html')
index.exposed = True
def ledDisplay(self, message):
if message:
raise cherrypy.HTTPRedirect("thanks.html") /* This prevents the loop from
executing. Any way to open the page and still execute the loop*/
while True:
//Execute LED code on loop.
Apologies if I'm being obtuse - I am new to programming.
--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.