在ubuntu服务器上上传flask应用程序时,无法重定向到__init__.py



我对web开发非常陌生,我正在使用这两种方法(两者相同(将flask应用程序部署到ubuntu vps。

https://www.digitalocean.com/community/tutorials/how-to-deploy-a-flask-application-on-an-ubuntu-vps

https://www.youtube.com/watch?v=YFBRVJPhDGY

我的文件夹结构是这样的:

|--------cwh
|----------------cwh
|-----------------------static
|-----------------------templates
|-----------------------venv
|-----------------------__init__.py
|----------------cwh.wsgi

以下是我的__init__.py:代码

from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return "Hello, I love my first website!"

以下是我的cwh.wsgi文件代码:

#!/usr/bin/python3
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/cwh/")
from cwh import app as application
application.secret_key = 'Add-secret'

以下是我在/etc/apache2/sites-available上传的cwh.conf文件的代码

<VirtualHost *:80>
ServerName 143.198.190.148
ServerAlias www.saassusar.com
ServerAdmin saassusar@gmail.com
WSGIScriptAlias / /var/www/cwh/cwh.wsgi
<Directory /var/www/cwh/cwh/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/cwh/cwh/static
<Directory /var/www/cwh/cwh/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

问题是经过多次尝试后,我无法在ipad上显示__init__.py消息。而是显示默认的apache索引文件。即使没有静态文件夹,cwh.conf激活也不会显示任何错误。

提供的详细信息似乎不够,我试图重现错误,但没能做到。顺便说一句,为什么要将index.py文件命名为__init___.py第二,什么是cwh。最好包括完整的依赖关系,项目结构也需要修改。

最新更新