【发布时间】:2016-05-27 21:38:15
【问题描述】:
我正在关注教程here。
我的 nginx 文件:
server {
listen 80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri @application;
}
location @application {
include uwsgi_params;
uwsgi_pass unix:/tmp/uwsgi.sock;
}
}
终端的东西 - 激活 virtualenv 之后:
uwsgi -s /tmp/uwsgi.sock --module runserver --callable app --enable-threads --uid www-data --gid www-data
cat runserver.py
from __init__ import app
import routes
if __name__ == '__main__':
app.debug = True
app.secret_key = "BuckyCaptainAmericaHydraStarkTonyWidowBlack"
app.run(host='0.0.0.0', port=8080)
猫路线.py
from flask import Flask, render_template,request, session, redirect, url_for, flash, make_response
import datetime
import json
from bson.json_util import dumps
from controller import actionController
from controller import dataController
from controller import usersController
from controller import authController
import base64
from flask.ext.paginate import Pagination
from __init__ import app
@app.route('/')
def index():
return "<h1>Hello World</h1>"
这很完美!
但是,而不是 Hello World.. 如果做常规的事情。
@app.route('/')
def index():
if 'loggedin' in session:
authController.Auth.forward()
它引发内部服务器错误。
当我删除配置并执行时:
python3 runserver.py
完全没有问题,通过 shell 启动时效果惊人!
所以,如果我调用包含的文件(通过导入)并使用 uwsgi,它们就会停止工作。
【问题讨论】:
-
对不起,请解释一下....我该如何纠正这个问题?
-
也许写一个答案..?
-
没有Minimal, Complete, and Verifiable example 或实际错误(包括完整的回溯),这只是一个猜测。我用尽可能多的工作代码创建了一个本地应用程序,但我无法重现问题。看来我的猜测是错误的。
-
哦,等等……让它成为一个答案……你是真正的 MVP!!!!谢谢@dirn 迫不及待地想打勾你的答案! :D
标签: nginx flask python-3.4 uwsgi