0

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.

2
  • What specific path you are trying to access? Commented Apr 22, 2024 at 12:23
  • what python and flask version ur using Commented Apr 22, 2024 at 12:28

1 Answer 1

0

This bug is caused by NameCheaps Website Builder.

You can comment out the line below in your /public_html/.ht_access

RewriteRule ^(.*)$ ncsitebuilder/$1 [L,QSA]

This may of course interfer with the sitebuilder site you created. Below is the answer that the insufferable AI-support chatat NameCheap finally produced after I did most of the troubleshooting for them. You only need to change the .ht_access though, not delete the other files.

NameCheap Chatbot answer

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.