我正在尝试在 Ubuntu 上运行的 Flask 应用程序中运行名词短语分析,通过 gunicorn 和 nginx 提供服务。我收到一个错误 500,在 nginx、supervisor 或 unicorn 错误日志中没有(明显)记录错误。“supervisorctl tail app”也没有任何启示。
我的站点可用 nginx.conf:
server {
listen 80;
server_name [domain redacted];
charset utf-8;
client_max_body_size 75M;
access_log /var/log/nginx/nginx_access.log;
error_log /var/log/nginx/nginx_error.log;
location / { try_files $uri @app; }
location @app {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
我的主管 app.conf
[program:app]
command = gunicorn app:app -b localhost:8000
directory = /home/www/app
user = admin
我正在 app.py 中运行我的应用程序,其中包含以下内容(在 config.py 中遇到 DEBUG = False 和 True 的问题)
app = Flask(__name__, static_folder='static', static_url_path='/static')
app.config.from_pyfile('config.py')
if __name__ == '__main__':
app.run()
if not app.debug:
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.INFO)
app.logger.addHandler(stream_handler)
Config.py 很简单
DEBUG = False
ALLOWED_HOSTS=['*']
我正在调用的名词短语功能
from textblob import TextBlob
def generateNounPhrases(input):
blob = TextBlob(input)
np = blob.noun_phrases
return np
页面的 app.py 烧瓶路由,传递 generateNounPhrases() 的输出
@app.route('/thread', methods=['GET'])
def thread():
...
nounphrases = generateNounPhrases(text_to_analyze)
...
return render_template("Thread.html", nounphrases=nounphrases)
我完全迷路了,在这方面绝对是新手。任何指导都将是巨大的!