I have 2 flask app, client and server respectively And I wanna download some files from server by redirecting user directly to the server So basically I want redirect to this route:
@app.route('/api/1.0/conf/<token>', methods=['GET']) def returnPeerConf(token): if token is valid: return file
So I’m write client like this:
@app.route("/downloadConf/<token>", methods=["GET"]) def downloadConf(token): url = f"http://{ipAddress}/api/1.0/conf/{token}" redir = redirect(url) return redir
I wanna get url like: http://ipAddress/api/1.0/conf/myGreatToken
But get: http://ipAddress/api/1.0/conf/%7B'token':%20'myGreatToken'%7D
And this doesn’t work. How to redirect without params?
Advertisement
Answer
It seems like token is a dict value. Perhaps you could try getting the value for token['token']
and then add it to the url, instead of putting the entire token
dict in.
For example:
app.route("/downloadConf/<token>", methods=["GET"]) def downloadConf(token): token_val = token['token'] url = f"http://{ipAddress}/api/1.0/conf/{token_val}" redir = redirect(url) return redir