vercel dev
with Python runtime downloads index.py
file instead of running function
#2768
Replies: 3 comments
-
I was having the same issue so I did something like this "fastapi-dev": "pip3 install -r requirements.txt && python3 -m uvicorn api.index:app --reload", I would just edit the run command for example if I updated index to foo I would do api.foo:app this worked for me Hope this helps |
Beta Was this translation helpful? Give feedback.
-
i am not using fastapi but I am having the same issue |
Beta Was this translation helpful? Give feedback.
-
If you set Vercel project root to default that is to the root of repo (just don't modify vercel root path) then you can go with: |
Beta Was this translation helpful? Give feedback.
-
Page to Investigate
https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/python
Steps to Reproduce
I have a monorepo containing a number of Vercel projects. One of said Vercel projects is for functions only. I'm trying to create a Python function within the
/api/test
directory, like so:The Python function is using FastAPI:
However, I've had this issue with the HTTP example provided in the docs.
Essentially, when I run
vercel dev
from the root of my repo (which has beenvercel link
ed to my functions project) and navigate tolocalhost:3000/api/test
, my browser tries to download theindex.py
file instead of running the function.If I rename
index.py
tofoo.py
and head to/api/test/foo
, I get a 502 error:None of this happens when deployed though - it all works just fine.
Any suggestions as to what I'm doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions