Here is my python code
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello World!'
def Fun():
return 'Having Fun!'
if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
On loading the www.example.com/ it goes to the hello function and returns Hello World!
How to point a url like www.example.com/Fun to another function Fun
Update(Working Code)
Updated code but still not working
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello World -- jay!'
@app.route('/fun')
def fun():
return 'have func!'
if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
Decorator @app.route sets url for your controller. So this code should work: