2

I want to deploy my flask-restx application on a shared hosting. Since I am beginner in deployment, I followed a video tutorial from youtube. I did step by step by following this tutorial. For those who do not want to go through the tutorial, I am writing the steps:

  1. I created an application from the Python cPanel Initial set up in Cpanel
  2. Then I opened terminal and changed my venv and installed flask by "pip install flask"
  3. Project Structure
filas_folder/
├──public
├──tmp
│   └──restart.txt 
├──app.py
└──passenger_wsgi.py

app.py looks like

from flask import Flask
app = Flask(__name__)

@app.route("/")
def main_():
        return "flask is running"

@app.route("/user")
def main_2():
        return "user is running"



if __name__ == "__main__": app.run()
  1. Restart app from cpanel

passenger.py looks like

import imp
import os
import sys


sys.path.insert(0, os.path.dirname(__file__))

wsgi = imp.load_source('wsgi', 'app.py')
application = wsgi.app

when I open www.example.com

flask is running

But when I open www.example.com/user

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@example.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

My system has cloudlinux and uses apache server. This is not the first deployment. Many wordpress and static websites are running on the server. I opened apache logs at /usr/local/apache/logs/error_log I get the error "Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer" http://example.com/user"

  • I will turn a link from an answer below into a duplicate-proposal-close-vote. Please double check however before agreeing with me. ;-) – Yunnosch Jun 29 '21 at 06:25
  • Does this answer your question? [Python flask app routing in cpanel: can only access root url](https://stackoverflow.com/questions/63106913/python-flask-app-routing-in-cpanel-can-only-access-root-url) – Yunnosch Jun 29 '21 at 06:25

1 Answers1

0

Add the following to the top of your .htaccess file:

RewriteEngine on  
RewriteRule ^http://%{HTTP_HOST}%{REQUEST_URI} [END,NE]

Got this info from: https://stackoverflow.com/a/63971427/10122266

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
taiff
  • 89
  • 8
  • If it is a duplicate question, [vote to close](//stackoverflow.com/help/privileges/close-questions) as such and/or leave a comment once you [earn](//meta.stackoverflow.com/q/146472) enough [reputation](//stackoverflow.com/help/whats-reputation). If not, *tailor the answer to this specific question*. Then this is a nice answer, no need to ask for permission to ignore the commenting rule. You do however now have the commenting privilege, so if you really still think that this should be a comment please turn it into one. – Yunnosch Jun 29 '21 at 06:20
  • Because you knew about the commenting privilege which you did not have, so well that you can even put it into words. You are aware of the rule https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead . In that situation please do not decide to misuse a different mechanism (an answer) for something it is not meant for and which you are not allowed yet to do. – Yunnosch Jun 29 '21 at 06:21