skip to Main Content

I am deploying Flask on CPanel, and basic configurations are working correctly,
up to the point that I can access home route, defined as:

@app.route("/home")
@app.route("/")
def home():
   return "This is home page, blah blah blah"

The site can be thought of, as being accessed at
https://sub-domain.main-domain.com/base-url,

thus, home page is accessed as https://sub-domain.main-domain.com/base-url/ and that works perfectly.

Problem

So, the issue comes when I access any other route, other than the slash("/"),
in the above example, for instance, accessing

https://sub-domain.main-domain.com/base-url/home,

doesn’t seem to work at all, and results in

The configuration file does not exist. error.

Any possible help would be kindly appreciated. my passenger_wsgi.py is configured as:

import sys

# add your project directory to the sys.path
base_dir = u'/home/cpaneusername/base-dir'
if base_dir not in sys.path:
    sys.path = [base_dir] + sys.path

# import flask app but need to call it "application" for WSGI to work
from app import website as application

Nevertheless, thanks for the assistance.

2

Answers


  1. Chosen as BEST ANSWER

    I tried moving the Python app and other supporting modules to /public folder, and in the wsgi file, I imported as

    from public.app import website as application
    

    There, it worked.


  2. What I can suggest resolving the issue is to change the base URL of your Python app and remove any sub-folders from it. For example, just keep it that way:

    https://sub-domain.main-domain.com/

    And try again.

    Otherwise, you might want to change the /home route of your app to this one instead:

    @app.route("/base-url/home")

    If none of the above works, then make sure that you have the correct .htaccess rules in place to forward the requests properly to your app, but I assume you already have considering the fact that you are able to access the / of the app.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search