avalanche avalanche - 3 years ago 311
Python Question

why i am getting error when i write the "localhost:40000/music/?name=william" in chrome webbrowser

when i write localhost:40000/?name=william it works.

so why is it not working for localhost:40000/music/?name=william

from flask import *

app = Flask(__name__)

def music():
return "<h1>Hello, {0}</h1>".format(request.args.get('name'))

def index():
return "<h1>Hello, {0}</h1>".format(request.args.get('name'))

if __name__ == '__main__':
app.run(host='localhost', port=40000,debug=True)

Answer Source

/music/ and /music are two different endpoints.

Your code handles requests for the latter; the URL you entered in your browser is for the former.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download