I'm currently trying to host my Flask application on Vercel, but I keep getting the same error,TypeError: issubclass() arg 1 must be a class
Full log:
[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
I tried to change typing_extension
to 4.5.0, typing-inspect
to 0.8.0, andpydantic
to 1.10.11, (as recommended here, but I still kept having the same issue.
Thanks in advance.
I managed to find an answer; I had configured vercel incorrectly.
I used server.py
as my main method, but vercel requires an index.py
file. So I created an index.py file, that was a single line; from server import app
.
then vercel.json
:
Old:
{ "version": 2, "builds": [ { "src": "./server.py", "use": "@vercel/python" } ], "routes": [ { "src": "/(.*)", "dest": "/server.py" } ] }
New:
{ "version": 2, "builds": [ { "src": "./index.py", "use": "@vercel/python" } ], "routes": [ { "src": "/(.*)", "dest": "/" } ] }