Handling POST; independant handlers for different pages

1 view
Skip to first unread message

Asim

unread,
Jul 28, 2009, 11:03:36 PM7/28/09
to aspen-users
Hi,

I'm relatively new to web programming and servers. I chose aspen
because i needed something I could setup quickly and get cracking.

I firstly would like to tell you that we really need more
documentation. As a newbie, I'm left quite high and dry with a few
vids and a 24 page pdf. A detailed how to would be nice.

Secondly, I tried writing a simplate (by embedding python code in the
web page). I used the 0x0c character to separate the html and python
content, but nothing seemed to happen. All the python code appeared on
the page like plain text

Thirdly, I want to know if it is possible to write handlers for
different/individual files instead of a whole type of files. Can I
write a handler for index.html and page1.html instead of writing one
common handler for *.html? If it cannot be done, do I have to identify
the file within the handler and make sub cases for each file? When I
write a handler, why must it always return something iterable?

Here's a thing that I want to do to start off. I want to create a page
which uses a form to take in username and password data. The OK button
is then used to post this data to aspen web server. I want to be able
to handle this POST request using a handler or something, and
depending on the authenticity of the data send a "success" or
"failure" page. Is it possible to return a href from the handler to a
page in the local directory, instead of returning a string?

How do i handle post requests? I saw an earlier discussion where Chad
has embedded some py code in the page itself. But as I said, my
browser is treating it as plain text. I have not made any mistakes and
my aspen is installed correctly. I am using the ^L(0x0c) character to
separate the py section from the page html.

Can you please shed light on any of these issues.

Thanks
Asim

Chad Whitacre

unread,
Jul 29, 2009, 9:40:48 AM7/29/09
to Asim, aspen-users
Asim,

Thanks for giving Aspen a try. Sorry for the lack of documentation and the rough edges. I would like to make Aspen more user friendly in the future. Oh for more hours in a day ...

I would recommend getting simplates to work rather than writing your own handler. Handlers have to return iterables because they are WSGI callables. WSGI is a low-level Python web spec that you don't want to mess with as a newbie.

The problem with simplates (Python code showing up in the browser) sounds like a wiring problem. Could you post a copy of your handlers.conf file? Also a copy of the simplate you are working with.


chad
Reply all
Reply to author
Forward
0 new messages