Forums

How to render basic sum in Flask?

I want this to show up online:

def my_function(x): return 5 * x

print(my_function(3)) print(my_function(9))

have tried this in the app route:

@app.route('/math') def my_function(x): return 5 * x

print(my_function(3)) print(my_function(9))

I know this isn't the way to do it, and just gives 'internal server error'

anyone know how to do?

thanks

so I'm figuring there must be some kind of Html button to be rendered for user to 'submit' this sum activation?

basically, I just want someone to go to the page and the numbers 15 and 45 to show up

Try this:

@app.route('/math/<x>')
def my_function(x)

Check out this blog post on converting a function to a Flask website.

ok, thanks