Below is my flask code and it's working fine
from flask import Flask
app = Flask(__name__)
@app.route("/")
@app.route("/hello")
def hello_world():
return "Hello, World!"
@app.route("/test")
def search():
return "Hello"
if __name__ == "__main__":
app.run()
but when I am adding the this code
@app.route("/test/<search_query>")
def search(search_query):
return search_query
it's giving the following error
Traceback (most recent call last): File "app.py", line 19, in def search(search_query): File "C:\Users\khadush\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 1315, in decorator self.add_url_rule(rule, endpoint, f, **options) File "C:\Users\khadush\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 98, in wrapper_func return f(self, *args, **kwargs) File "C:\Users\khadush\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 1282, in add_url_rule raise AssertionError( AssertionError: View function mapping is overwriting an existing endpoint function: search