Jump to content

[Solved] Request for WSGI Control


ujcis

Recommended Posts

WSGI control access has been enabled on the domain alutagram.helioho.st. To restart your Flask app and load new code changes in simply edit /home/ujcis.helioho.st/alutagram.helioho.st/flask.wsgi. Adding a blank line, removing a blank line, adding a space, or removing a space are examples of editing the file. As long as the last modified timestamp changes it will clear the server cache. Let us know if you run into any issues.

Link to comment
Share on other sites

Thanks, but I still have some challenges. I'm not really sure how python/flask works on additional domains. My new alutagram.helioho.st folder contains a cgi-bin folder and an index.html file. 

Things I've tried to get Flask running:

1. I've tried making the required files from the tutorial: https://wiki.helionet.org/tutorials/flask

2. I followed the tutorial on https://wiki.helionet.org/tutorials/python and made the test.py executable file in the new cgi-bin folder. 

Result:

Flask wasn't running so I made a .htaccess file with the following content in the alutagram.helioho.st folder: 

`

Options +ExecCGI

RewriteEngine On

RewriteBase /

RewriteRule ^(media/.*)$ - [L]

RewriteRule ^(admin_media/.*)$ - [L]

RewriteRule ^(flask\.wsgi/.*)$ - [L]

RewriteRule ^(.*)$ flask.wsgi/$1 [QSA,PT,L]

The HTACCESS file causes an Internal Server Error, but nothing shows in my error_log

Link to comment
Share on other sites

48 minutes ago, ujcis said:

1. I've tried making the required files from the tutorial: https://wiki.helionet.org/tutorials/flask

This guide is for Flask which uses WSGI.

48 minutes ago, ujcis said:

2. I followed the tutorial on https://wiki.helionet.org/tutorials/python and made the test.py executable file in the new cgi-bin folder. 

This guide is for Python CGI.

CGI and WSGI are two very different mechanisms for running Python code. Which are you trying to do exactly because they aren't the same thing, and it was never intended to do both guides at the same time?

Link to comment
Share on other sites

Posted (edited)

Oh, for some silly reason I thought getting flask to work required getting Python CGI to work first. 

My intention is to get Flask running on the new domain. I've deleted the test.py from cgi-bin folder leaving flask.wsgi, .htaccess, and myapp.py in the root. But flask still doesn't work. 

Also I've noticed a new folder in my log folder corresponding to my new domain, however it's empty even though I'm getting an Internal Server error. 

Edited by ujcis
More details
Link to comment
Share on other sites

Plesk still isn't filtering the new logs correctly either

[Wed Oct 09 02:20:41.641245 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078] mod_wsgi (pid=4180750): Failed to exec Python script file '/home/ujcis.helioho.st/alutagram.helioho.st/flask.wsgi'.
[Wed Oct 09 02:20:41.641414 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078] mod_wsgi (pid=4180750): Exception occurred processing WSGI script '/home/ujcis.helioho.st/alutagram.helioho.st/flask.wsgi'.
[Wed Oct 09 02:20:41.642342 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078] Traceback (most recent call last):
[Wed Oct 09 02:20:41.643060 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078]   File "/home/ujcis.helioho.st/alutagram.helioho.st/flask.wsgi", line 7, in <module>
[Wed Oct 09 02:20:41.643104 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078]     from myapp import app as application
[Wed Oct 09 02:20:41.643155 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078]   File "/home/ujcis.helioho.st/alutagram.helioho.st/myapp.py", line 12, in <module>
[Wed Oct 09 02:20:41.643181 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078]     db = SQLAlchemy(app)
[Wed Oct 09 02:20:41.643199 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078]          ^^^^^^^^^^^^^^^
[Wed Oct 09 02:20:41.643241 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078]   File "/usr/local/python3.12/lib/python3.12/site-packages/flask_sqlalchemy/extension.py", line 278, in __init__
[Wed Oct 09 02:20:41.643265 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078]     self.init_app(app)
[Wed Oct 09 02:20:41.643306 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078]   File "/usr/local/python3.12/lib/python3.12/site-packages/flask_sqlalchemy/extension.py", line 373, in init_app
[Wed Oct 09 02:20:41.643331 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078]     self._apply_driver_defaults(options, app)
[Wed Oct 09 02:20:41.643373 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078]   File "/usr/local/python3.12/lib/python3.12/site-packages/flask_sqlalchemy/extension.py", line 627, in _apply_driver_defaults
[Wed Oct 09 02:20:41.643412 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078]     os.makedirs(app.instance_path, exist_ok=True)
[Wed Oct 09 02:20:41.643456 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078]   File "<frozen os>", line 225, in makedirs
[Wed Oct 09 02:20:41.643560 2024] [wsgi:error] [pid 4180750:tid 4180815] [remote x.x.x.x:55078] PermissionError: [Errno 13] Permission denied: '/home/ujcis.helioho.st/alutagram.helioho.st/instance'

It looks like your Flask app is trying to create a new directory and getting denied due to permissions. In order to create a directory you probably need to give 777 permissions to the directory above it, but why are you trying to create a directory anyways? Seems kind of odd. Just create the directory yourself through SFTP or Plesk File manager and it will be 10,000% easier.

Link to comment
Share on other sites

I did a little research on wsgi logs and it basically boils down to: Some types of errors go to the virtualhost log, which you have access to, and other types of errors go to the main system error log, which you do not have access to. It is not possible to securely give you access to just your parts of the main system error log because it contains the private information of thousands of other people on the server.

So, the reason your other project was putting its errors directly into the log you have access to is because it was the right type of error. The type of error I posted above apparently always goes into the main system error log. So fix the above error and the rest of your errors should hopefully go into the log you can see.

Link to comment
Share on other sites

  • Krydos locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...