Re: [web2py] Setting up nginx to enable CORS for a specific function?

2019-05-01 Thread leandro . salgueiro
Thanks Michele, although is an old post you saved my day!! :-) Le mercredi 26 octobre 2016 22:01:06 UTC+2, mcm a écrit : > > You can do that easily in web2py... > > Below is a sample of a decorator that allows any origin. > Change it to fit your needs. > > You can use in a controller like: > >

Re: [web2py] Setting up nginx to enable CORS for a specific function?

2016-10-27 Thread Spokes
For reasons that are not entirely clear to me yet, request.vars suddenly started showing the expected content... Thanks, I'll read up on the Restful and json services portions of the book. On Thursday, October 27, 2016 at 1:43:41 PM UTC-4, mcm wrote: > > You did not POST any multipart/mime or

Re: [web2py] Setting up nginx to enable CORS for a specific function?

2016-10-27 Thread Michele Comitini
You did not POST any multipart/mime or form encoded var so no request.vars. you should probably read the request.body content for JSON. try to look into restful services or json services (see the book) to have that done automagically... 2016-10-27 17:17 GMT+02:00 Spokes

Re: [web2py] Setting up nginx to enable CORS for a specific function?

2016-10-27 Thread Spokes
Thanks, Michele; that worked like a charm! The only issue is that request.vars is empty - any idea as to what could be causing that? On Wednesday, October 26, 2016 at 4:01:06 PM UTC-4, mcm wrote: > > You can do that easily in web2py... > > Below is a sample of a decorator that allows any

Re: [web2py] Setting up nginx to enable CORS for a specific function?

2016-10-26 Thread Michele Comitini
You can do that easily in web2py... Below is a sample of a decorator that allows any origin. Change it to fit your needs. You can use in a controller like: @cors_allow def action(): . . . return dict(...) -- def cors_origin(): origin = request.env.http_origin

[web2py] Setting up nginx to enable CORS for a specific function?

2016-10-26 Thread Spokes
This isn't necessarily a web2py-specific question, but perhaps there's a web2py-specific solution that's preferable to other solutions, so I thought I'd ask it here. I have some HTML code and javascript, which I'd like to be able to paste into any website, and which should access an API