0

I'm trying to create a simple Flask application that takes in url parameters and returns the times table. The code I used is:

@app.route ( '/multiply/<x>' )
def get_table( x ):
    y= (x, x*1, x*2)
    return tuple(y)

I've tried creating a list of the products and passing x though them, this doesn't work unless I assign a value to x by hard coding it. Currently trying a simple function with a list and getting the error:

ValueError: not enough values to unpack (expected 2, got 1)
Anwarvic
  • 12,156
  • 4
  • 49
  • 69

1 Answers1

0

You are using flask template to call the function so where your x comes from? Try this:

@app.route ( '/multiply/<x>' )
def get_table( x ):
    y= (x, x*1, x*2)
    return tuple(y)

and go to your_url/multiply/your_x_value

Kostas Charitidis
  • 2,991
  • 1
  • 12
  • 23