0

How can I pass myvariable to the app in the below code? myvariable is a variable that comes from the rest of the code rather than being received from the URL.

@app.route("/myrout", methods=["GET"])

def myfunction(myvariable):

Admia
  • 1,025
  • 3
  • 12
  • 24

1 Answers1

0
global myvariable=8

@app.route("/myrout", methods=["GET"])
def myfunction():
    global myvariable
    local_variable=myvariable
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Admia
  • 1,025
  • 3
  • 12
  • 24
  • You should read this: [Are global variables thread-safe in Flask? How do I share data between requests?](https://stackoverflow.com/q/32815451/2745495) – Gino Mempin Oct 14 '21 at 13:27