簡體   English   中英

在 pythonanywhere 設置 wsgi.py

[英]Setup wsgi.py at pythonanywhere

我有 wsgi.py 問題,誰能幫我解決這個問題?

我的面包屑結構是: https://www.pythonanywhere.com/user/alinecatikoc/files/var/www/alinecatikoc_pythonanywhere_com_wsgi.py?edit

我里面的wsgi.py文件是這樣的:

import sys
#
## The "/home/alinecatikoc" below specifies your home
## directory -- the rest should be the directory you uploaded your Flask
## code to underneath the home directory.  So if you just ran
## "git clone git@github.com/myusername/myproject.git"
## ...or uploaded files to the directory "myproject", then you should
## specify "/home/alinecatikoc/myproject"
path = '/home/alinecatikoc/flaskai/app.py'
if path not in sys.path:
   sys.path.insert(path)

import os
from dotenv import load_dotenv
project_folder = os.path.expanduser(path)  # adjust as appropriate
load_dotenv(os.path.join(project_folder, '.env'))

from flaskai import app as application
application = app

我的錯誤日志位於https://www.pythonanywhere.com/user/alinecatikoc/files/var/log/alinecatikoc.pythonanywhere.com.error.log

2022-08-11 19:31:47,880: Error running WSGI application
2022-08-11 19:31:47,882: NameError: name 'app' is not defined
2022-08-11 19:31:47,883:   File "/var/www/alinecatikoc_pythonanywhere_com_wsgi.py", line 89, in <module>
2022-08-11 19:31:47,883:     application = app
2022-08-11 19:31:47,883: ***************************************************
2022-08-11 19:31:47,883: If you're seeing an import error and don't know why,
2022-08-11 19:31:47,883: we have a dedicated help page to help you debug: 
2022-08-11 19:31:47,883: https://help.pythonanywhere.com/pages/DebuggingImportError/
2022-08-11 19:31:47,883: ***************************************************
2022-08-11 19:31:52,038: Error running WSGI application
2022-08-11 19:31:52,038: NameError: name 'app' is not defined
2022-08-11 19:31:52,038:   File "/var/www/alinecatikoc_pythonanywhere_com_wsgi.py", line 89, in <module>
2022-08-11 19:31:52,039:     application = app
2022-08-11 19:31:52,039: ***************************************************
2022-08-11 19:31:52,039: If you're seeing an import error and don't know why,
2022-08-11 19:31:52,039: we have a dedicated help page to help you debug: 
2022-08-11 19:31:52,039: https://help.pythonanywhere.com/pages/DebuggingImportError/
2022-08-11 19:31:52,039: ***************************************************
2022-08-11 19:39:16,449: Error running WSGI application
2022-08-11 19:39:16,450: TypeError: 'module' object is not callable
2022-08-11 19:39:25,030: Error running WSGI application
2022-08-11 19:39:25,032: TypeError: 'module' object is not callable
2022-08-11 19:39:26,579: Error running WSGI application
2022-08-11 19:39:26,579: TypeError: 'module' object is not callable

我的問題是,首先,該網站無法正常工作。 其次是我無法弄清楚我的 sqlalchemy 和數據庫是否工作?

最后我的文件結構是:

/home/
  alinecatikoc/
    flaskai/
      app.py
      requirements.txt
      aiusers.db
      .env
      .emv
      .gitignore

謝謝你的熱心幫助。

您必須刪除application = app

您沒有app ,因為您將其作為app as application導入 - 所以現在它的名稱為application ,而不是app


pythonanywhere.com上的文檔也顯示它沒有application = app

請參閱: Flask - 配置-the-wsgi-file


但是您的結構表明您應該從flaskai.app導入

from flaskai.app import app as application

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM