1

I have a flask app and I need to pass variables from one function to another. The requirement here is I need to pass the value of 'skill' from index() to get_image(), any idea on how this can be achieved?

@app.route('/', methods=['POST'])
def index():
    data = json.loads(request.get_data())
    skill = data['conversation']['skill']


@app.route("/get-image/<image_name>")
def get_image(image_name):
    if skill == 'getpositions':
        # some code

1 Answer 1

4

You can try use flask sessions for example:

from flask import Flask, session

...

@app.route('/', methods=['POST'])
def index():
    data = json.loads(request.get_data())
    skill = data['conversation']['skill']
    session['skill'] = skill

@app.route("/get-image/<image_name>")
def get_image(image_name):
    if session['skill'] == 'getpositions':
    #some code

Check the documentation.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.