【问题标题】:Flask + uwsgi + nginx: TypeError: ... takes no arguments (2 given)Flask + uwsgi + nginx: TypeError: ... 不接受任何参数(给定 2 个)
【发布时间】:2013-02-13 06:08:23
【问题描述】:

我在我的 ubuntu 12.04 homerserver 上安装了带有 nginx 的 uwsgi,并尝试测试一个简单的 Flask-App:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def application():
    return 'Hello World!'

if __name__ == '__main__':
    app.run()

python app.py 一起工作。 但不是uwsgi --socket 127.0.0.1:3031 --file /srv/www/test/app.py --callable application --catch-exceptions

我刚刚收到此错误TypeError: application() takes no arguments (2 given),但不知道为什么。这两个论点从何而来?

这是我的 uwsgi.conf:

  1 description "uWSGI Emperor"
  2 start on runlevel [2345]
  3 stop on runlevel [06]
  4 respawn
  5
  6 exec uwsgi --master --die-on-term --emperor /etc/uwsgi/apps-enabled

还有我的 nginx.conf

server {
 94      listen 8000;
 95      server_name localhost;
 96      root /srv/www/test;
 97
 98      location /static/ {
 99      alias /srv/www/test/static/;
100      expires 30d;
101      access_log off;
102      }
103
104      location / {
105      include uwsgi_params;
106      uwsgi_pass 127.0.0.1:3031;
107  }
108 }

我之前在启用应用程序中使用 .ini 文件尝试过,但我也遇到这种错误。

我希望有人可以帮助我。 :\

【问题讨论】:

    标签: python nginx flask uwsgi


    【解决方案1】:

    “应用程序”是一个可调用的烧瓶(由您定义)而不是可调用的 WSGI(就像您在 uWSGI 中配置的那样)。您的 WSGI 可调用对象是“app”(主入口点)。只需将 --callable application 更改为 --callable app

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-19
      • 1970-01-01
      • 1970-01-01
      • 2021-12-04
      • 1970-01-01
      • 2019-09-12
      • 2016-02-03
      相关资源
      最近更新 更多