Nowadays,web application uses custom url instead of using language specific.For SEO , custom URL is best.And people can easily remember this kind of URL.So they can easily access the page by typing the URL in browser directly. This can be achieved by flask very easily.

Syntax:

<variable_name> or <converter:variable_name>

The following converters exist:

int accepts integers
float like int but for floating point values
path like the default but also accepts slashes

 


@app.route("/<name>")

Here name is a variable.

Source Code:


from flask import Flask
app = Flask(__name__)

@app.route("/<name>")
def hello1(name):
    return "Hello "+name
if __name__ == "__main__":
    app.run()

Run this file and browse http://127.0.0.1:5000/Raja. It will display Hello Raja.

flask-routing-example