Azad Rasul
SmartRS

Follow

SmartRS

Follow

5-Routing in Flask

Azad Rasul's photo
Azad Rasul
·Jan 3, 2023·

1 min read

Play this article

Modern web applications apply meaningful URLs to assist users to come back to them easily when they can remember them.

Use the route() decorator to connect a function to a URL.

We can use index route ('/') and then define it:

@app.route('/')
def index():
    return 'index.html'

if __name__ == "__main__":
    app.run(debug=True)

Or we can use hello route and then define it to return "Hello, Welcome to blog SmartRS!" directly:

@app.route('/hello')
def hello():
    return 'Hello, Welcome to blog SmartRS!'

if __name__ == "__main__":
    app.run(debug=True)

Run the application using:

python "filename".py

* If you like the content, please SUBSCRIBE to my channel for the future content

 
Share this