2010/11/24 Pepe <[email protected]>:
> Hi there,
>
> I am using a server using web.py
>
> The ctx.environ has a lot of information from the client requesting
> information. One in particular is that the client may request to get
> the response with either json or xml.
>
> I would like to know how can I do both things. How can I, as client,
> request for the xml or json format. I know it should be with
> http_variables, but I am not sure how can I request this. Do they have
> to be sent by POST?
>
> And while extracting information, how would it be? Do I have to
> extract a param from web.ctx.environ['HTTP_ACCEPT'] or right away with
> web.ctx.environ['HTTP_REQUEST']
>
> Thanks in advance and I hope anybody can help me with this.

Yes, you need to parse HTTP_ACCEPT.

Here is a sample code to parse that header. Feel free to adopt it for
your needs.

https://github.com/openlibrary/infogami/blob/master/infogami/utils/app.py#L197

Anand

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to