Simple Web Greeting Route Creation

  • Share this:

Code introduction


This function creates a simple web route that responds to HTTP GET requests. Users can get a greeting by accessing the /greet/ path followed by a name.


Technology Stack : Bottle

Code Type : Web framework

Code Difficulty : Intermediate


                
                    
from bottle import route, run, request, response

def create_route():
    @route('/greet/<name>')
    def greet(name):
        response.content_type = 'text/html'
        return f'Hello, {name}!'

    return greet                
              
Tags: