I have built a minimal Flask application and installed it in Namecheap shared hosting, following the instructions in https://dev.to/lordghostx/how-to-host-flask-applications-on-namecheap-cpanel-299b. Here's the code:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
@app.route("/<string:name>/")
def say_hello(name):
return f"Hello {name}!"
if __name__ == "__main__":
app.run()
The code works perfectly on my local PC with the development server.
After installing in Namecheap, the "/" path works correctly, but the /string:name/ path gives a 404 (not found) error.
There is nothing in the application stderr log file.
There are many online posts about the failure of Flask routing, but none quite fits this situation.
Any help, please.