librelist archives

« back to archive

Redirect form data extarnal URL with post

Redirect form data extarnal URL with post

From:
Raimon Esteve
Date:
2014-12-09 @ 15:32
Hie,

I like in a view redirect to extenal url and send form data with POST.

Idea is not render a form in template and user click a button to
redirect. I would like in view to redirect without render template.

How do it? Any ideas?

-- 
Raimon

Re: [flask] Redirect form data extarnal URL with post

From:
Laurent Meunier
Date:
2014-12-09 @ 15:51
On 09/12/2014 16:32, Raimon Esteve wrote:
> Hie,
>
> I like in a view redirect to extenal url and send form data with POST.
>
> Idea is not render a form in template and user click a button to
> redirect. I would like in view to redirect without render template.
>
> How do it? Any ideas?

Something like this?

http://flask.pocoo.org/docs/0.10/api/#flask.redirect


from flask import redirect

@app.route('/')
def hello():
     return redirect("http://www.example.com", code=302)


-- 
Laurent Meunier <laurent@deltalima.net>

Re: [flask] Redirect form data extarnal URL with post

From:
Raimon Esteve
Date:
2014-12-09 @ 16:11
2014-12-09 16:51 GMT+01:00 Laurent Meunier <laurent@deltalima.net>:
> On 09/12/2014 16:32, Raimon Esteve wrote:
>> Hie,
>>
>> I like in a view redirect to extenal url and send form data with POST.
>>
>> Idea is not render a form in template and user click a button to
>> redirect. I would like in view to redirect without render template.
>>
>> How do it? Any ideas?
>
> Something like this?
>
> http://flask.pocoo.org/docs/0.10/api/#flask.redirect
>
> from flask import redirect
>
> @app.route('/')
> def hello():
>      return redirect("http://www.example.com", code=302)

Yes, but this redirect send with GET.

I like to send a request data with POST, same an user click a button
form but without render a form.

A example form:

<form action="http://new-url.com/" class="form-inline
quick-search-form" role="form" method="post">
<input id="name" name="name" type="text" class="form-control
quick-search-input" placeholder="Name" value="my name">
<input id="phone" name="name" type="text" class="form-control
quick-search-input" placeholder="Phone" value="my phone">
<button type="submit"></button>
</form>

I like same when user do click form button but create python form or
request in view and redirect to http://new-url.com with POST data are:
name="my name", phone="my phone",....

Thanks

Re: [flask] Redirect form data extarnal URL with post

From:
Laurent Meunier
Date:
2014-12-09 @ 16:36
On 09/12/2014 17:11, Raimon Esteve wrote:
> 2014-12-09 16:51 GMT+01:00 Laurent Meunier <laurent@deltalima.net>:
>> On 09/12/2014 16:32, Raimon Esteve wrote:
>>> Hie,
>>>
>>> I like in a view redirect to extenal url and send form data with POST.
>>>
>>> Idea is not render a form in template and user click a button to
>>> redirect. I would like in view to redirect without render template.
>>>
>>> How do it? Any ideas?
>>
>> Something like this?
>>
>> http://flask.pocoo.org/docs/0.10/api/#flask.redirect
>>
>> from flask import redirect
>>
>> @app.route('/')
>> def hello():
>>       return redirect("http://www.example.com", code=302)
>
> Yes, but this redirect send with GET.
>

Most web browsers will change the request type to GET, regardless of the 
type used in the first request, when an HTTP response with a status code 
302 is received.
You can try code 303 or 307 instead.

http://en.wikipedia.org/wiki/HTTP_302

-- 
Laurent Meunier <laurent@deltalima.net>

Re: [flask] Redirect form data extarnal URL with post

From:
ydf
Date:
2014-12-10 @ 02:12
U mean this:

@app.route('/', methods=['POST']‍)  
def hello():
      return redirect("http://www.example.com", code=302)


‍


------------------ Original ------------------
From:  "Raimon Esteve";<raimonesteve@gmail.com>;
Date:  Wed, Dec 10, 2014 00:11 AM
To:  "flask"<flask@librelist.com>; 

Subject:  Re: [flask] Redirect form data extarnal URL with post



2014-12-09 16:51 GMT+01:00 Laurent Meunier <laurent@deltalima.net>:
> On 09/12/2014 16:32, Raimon Esteve wrote:
>> Hie,
>>
>> I like in a view redirect to extenal url and send form data with POST.
>>
>> Idea is not render a form in template and user click a button to
>> redirect. I would like in view to redirect without render template.
>>
>> How do it? Any ideas?
>
> Something like this?
>
> http://flask.pocoo.org/docs/0.10/api/#flask.redirect
>
> from flask import redirect
>
> @app.route('/')
> def hello():
>      return redirect("http://www.example.com", code=302)

Yes, but this redirect send with GET.

I like to send a request data with POST, same an user click a button
form but without render a form.

A example form:

<form action="http://new-url.com/" class="form-inline
quick-search-form" role="form" method="post">
<input id="name" name="name" type="text" class="form-control
quick-search-input" placeholder="Name" value="my name">
<input id="phone" name="name" type="text" class="form-control
quick-search-input" placeholder="Phone" value="my phone">
<button type="submit"></button>
</form>

I like same when user do click form button but create python form or
request in view and redirect to http://new-url.com with POST data are:
name="my name", phone="my phone",....

Thanks