I'm trying to emulate server side form post action at Flask. Throught using Requests lib I doing post action:
@flask_app.route('/hello',methods=['GET','POST'])
def hello():
r = requests.post(
"https://somesite.hello"
, data= {'user': 'bill','pass': 123})
return r.text
#return redirect("https://somesite.hello")
And it's work. But when I posting real form by html it also doing redirection. After #1 url will be http://mysite.hello:5000/hello, but I need contnent from #1 but url from #2 https://somesite.hello How to do 1 and 2 at same time? Thank you!
UPD:
I found some solution, i not really like it, because user will be see "Redirecting to billing page" page for a second. May be someone know how do requests and redirect to get some result?
@flask_app.route('/hello',methods=['GET','POST'])
def hello():
url = "https://somesite.hello"
return flask_app.make_response("""
<html>
<body onload='document.forms[0].submit()'>
Redirecting to billing page...
<form action='%s' method='post'>
<input type='hidden' name='user' value='%s'>
<input type='hidden' name='pass' value='%s'>
</form>
</body>
</html>
"""%(url
,'bill'
,123))