1

I have just found out this "feature" under my web hosting cPanel called "Setup Python App" and very much would like to play around with a nice flask app if I could however it does not seem to work so I come here looking for some help. Here is a brief description of the setup and it's symptoms:

cpanel setup python application

Clicking on this takes me to a very simple page asking for a directory and URI however when "setting it up" not much information is reported back but a directory is generated with a passenger_wsgi.py file with what looks like a basic server setup however trying to land on it simply downloads the file.

setting up options post setup

passenger_wsgi.py

import os
import sys


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


def application(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    message = 'It works!\n'
    version = 'Python %s\n' % sys.version.split()[0]
    response = '\n'.join([message, version])
    return [response.encode()]

To solve this I figured I would setup an Apache Handler to include .py under the cgi-script handlers which then makes landing on this page a simple 500 Server Error.

500 Internal Error

I am running out of ideas on how to get this working and can't find any documentation about this "Setup Python App" feature. If anyone has had experience with it I would very much appreciate some assistance. I have already reached out to web hosting support and they also do not know what is going on. I do suspect that there is a phusion passenger server that gets setup in the process but not correctly maybe? Also there doesn't seem to be a way for me to know which port it is running under and no redirect is automatically generated (I say this because when generating a Rails app an internal redirect is automatically created pointing to the correct internal port, which I would expect to happen here too).

Gustavo Hoirisch
  • 1,637
  • 12
  • 19
  • `/home/xxxxxx/` not a publishing directory. Check your apache template which directory can run `.py` files ? You got two different directory declaration. Easy add an app to on `apache directory` setting(be carefull : never touch root directory for apache). And you got a bug `don't publish any script outside, /var/www or default publish directory` – dsgdfg Jan 24 '16 at 11:22
  • This is shared hosting, I dont have access to root or anything outside of my home directory, much less apache configuration. – Gustavo Hoirisch Jan 24 '16 at 13:08
  • I can't imagine `how to set mode a+x ?` and `what include your .htaccess file ?` . So your script can't run on your server or haven't access for running it. – dsgdfg Jan 25 '16 at 14:52
  • I have set the script to `755` permission as this was at one point a problem indeed. I don't have any .htaccess files but I have managed to run other simple python scripts (standalone) but not one that actually runs a server (being `flask` or `phusion passenger` - none of them work so far) – Gustavo Hoirisch Jan 25 '16 at 23:35
  • This tutorial is helpful: http://calderonroberto.com/blog/how-to-deploy-a-flask-python-app-for-cheap/ – macloo Mar 11 '17 at 14:52

1 Answers1

1

I've had the Python file set at 644 and added the following to the top of my .htaccess file to allow both root URL and non-root URL to work:

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

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

Apologies that I couldn't add this as a comment as I do not have sufficient rights yet. But this solution worked for me and it would be a pitty if this little gem is hidden from those who may arrive here.

So would appreciate if this post is not deleted.

taiff
  • 89
  • 8