在cPanel和passenger_wsgi.py文件问题上运行Pyhon

时间:2019-01-27 22:27:50

标签: python cpanel wsgi

我通过其内嵌python模块在cPanel上设置了基于Python的Web应用程序。当我在浏览器中打开指定的URL时,唯一的结果就是passenger_wsgi.py文件的默认值,即使我更改了该文件的内容:

It works!

Python 3.7.2

我试图通过DreamHost中的以下代码解决此问题,但正如我所说的,passenger_wsgi.py文件的给定结果没有变化:

import sys, os
 cwd = os.getcwd()
 myapp_directory = cwd + '/myapp'
 sys.path.insert(0,myapp_directory)
 sys.path.append(os.getcwd())
 os.environ['DJANGO_SETTINGS_MODULE'] = "myapp.settings"
 from paste.exceptions.errormiddleware import ErrorMiddleware
 import django.core.handlers.wsgi
 application = django.core.handlers.wsgi.WSGIHandler()
 # To cut django out of the loop, comment the above application = ... line ,
 # and remove "test" from the below function definition.
 def testapplication(environ, start_response):
   status = '200 OK'
   output = 'Hello World! Running Python version ' + sys.version + '\n\n'
   response_headers = [('Content-type', 'text/plain'),
                       ('Content-Length', str(len(output)))]
   # to test paste's error catching prowess, uncomment the following line
   # while this function is the "application"
   #raise("error")
   start_response(status, response_headers)    
   return [output]
 application = ErrorMiddleware(application, debug=True)

如何从指定目录的public文件夹中设置项目?

我的项目是一个简单的纯python项目。

0 个答案:

没有答案