hello am trying to create flask api where user input the vaue and I will use that value to process my python code here is the code
`
app = Flask(__name__)
api = Api(app)
class Users(Resource):
@app.route('/users/<string:name>/')
def hello(name):
namesource = request.args.get('name')
return "Hello {}!".format(name)
print(namesource) # here am trying to get the sitring/value in name source but i can't because it no variable defines
api.add_resource(Users, name='users')
# For Running our Api on Localhost
if __name__ == '__main__':
app.run(debug=True)
`
am trying to expect that i get that value/String outside of the function of api flask
namesourceoutside of the scope of thehellofunction. The solution here is to access the rest of the code you wish to run from within the scope of thehellofunction. So bundle the rest of the code you wish to run in a function, and call that function from withinhello, passing in the variablenamesourceas an argument.