TypeError:issubclass() arg 1 必须是 Flask / Vercel 上的类

问题描述 投票:0回答:1

我目前正在尝试在 Vercel 上托管我的 Flask 应用程序,但我不断收到相同的错误,

TypeError: issubclass() arg 1 must be a class
完整日志:

[WARNING]   2024-03-01T18:22:28.551Z        Set both RATELIMIT_LIMIT and RATELIMIT_PERIOD in configuration. Default values are being used.
[ERROR] TypeError: issubclass() arg 1 must be a class
Traceback (most recent call last):
  File "/var/lang/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/var/task/vc__handler__python.py", line 31, in <module>
    if not issubclass(base, BaseHTTPRequestHandler):INIT_REPORT Init Duration: 2833.05 ms   Phase: invoke   Status: error   Error Type: Runtime.ExitError
Unknown application error occurred

我尝试将

typing_extension
更改为4.5.0,
typing-inspect
更改为0.8.0,并将
pydantic
更改为1.10.11(按照here的建议,但我仍然遇到同样的问题。

提前致谢。

python python-3.x flask cloud vercel
1个回答
0
投票

我设法找到了答案;我错误地配置了 vercel。 我使用

server.py
作为主要方法,但 vercel 需要
index.py
文件。所以我创建了一个index.py文件,它是一行;
from server import app
。 然后
vercel.json
: 旧:

{ “版本”:2, “构建”:[ { "src": "./server.py", “使用”:“@vercel/python” } ], “路线”:[ { “src”:“/(.*)”,“dest”:“/server.py” } ] }

新:

{ “版本”:2, “构建”:[ { "src": "./index.py", “使用”:“@vercel/python” } ], “路线”:[ { “src”:“/(.*)”,“dest”:“/” } ] }

© www.soinside.com 2019 - 2024. All rights reserved.