这是我的python代码
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)
在加载www.example.com/
它时,它会转到hello
函数并返回Hello World!
How to point a url like www.example.com/Fun
to another functionFun
更新(工作代码)
更新了代码但仍然无法正常工作
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)