DEV Community

Dr. Azad Rasul
Dr. Azad Rasul

Posted on

5-Routing in Flask Framework

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)
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

Run the application using:

python "filename".py
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)