404仅使用Gunicorn/nginx时出现"未找到"错误



我有一个flask应用程序,我正在Ubuntu 18.04服务器上通过gunicorn和nginx运行。我有几个路由文件,都导入到__init__.py,一般来说,工作得很好。我为其中一个文件添加了一个新的路由,基本上和其他文件一样。该路由在我的开发机器上本地运行得很好,但当我在服务器上运行相同的代码时,我会得到404错误。

我完全被难住了。

以下是一个无效的路由文件片段:

# This route works fine
@app.route('/admin/monthy_bad')
@login_required
def monthly_bad():
monthly_bad = admin_utilities.monthly_bad(current_user.admin, current_user.domain_group_id)
return render_template('monthly_bad.html', name=current_user.name, monthly_bad=monthly_bad)
# This route fails with 404 on the server, but not locally
@app.route('/domain_group/admin')
@login_required
def domain_group_admin():
"""
Admin page for domain groups
"""
no_domain_group = DomainGroup.query.filter_by(name='None').first_or_404()
if current_user.domain_group_id == str(no_domain_group.id): # bump them
flash("No Domains!")
return redirect(url_for('profile'))
else:
return render_template('domain_group_admin.html', name=current_user.name, domain_group_id=current_user.domain_group_id)

我认为这可能是一个缓存问题,但我已经重新启动了应用程序好几次(甚至重新启动了服务器(

任何关于在哪里进行故障排除的想法都会非常有用。

furas有正确的答案,这正是问题所在!我需要的数据在服务器上丢失,first_or_404()返回404错误。

相关内容

最新更新