DEV Community

Discussion on: How to deploy a Python/Flask App to Vercel

Collapse
 
josiasaurel profile image
Josias Aurel

I am using a terminal emulator Termux which emulates Linux pretty well. I don't know if that's the problem. I'll retry

Thread Thread
 
headwinds profile image
brandon flowers • Edited

I'm also interested in this demo. Big thank you Andrew for writing it up!

I too was able to get your demo running locally but when I deployed it to Vercel - I also the got the bad gateway error! It deployed successfully and I can see in my builds logs that it looks good.

In the past, I have been able to deploy a Flask app to Vercel though so I'm troubleshooting too to see if I can see what has changed.

I'm on a Mac and share same environment as Andrew. I'll try to find what's going on and report back.

Thread Thread
 
headwinds profile image
brandon flowers

Just a follow up.... in my case, I forgot to include the requirements.txt file.

Once I added the requirements, I was able to deploy the app:

venv.headwinds1.vercel.app/

Thread Thread
 
josiasaurel profile image
Josias Aurel

I don't know what's happening really. I rebuilt the app three times and nothing. I'll retry one more time ;/

Thread Thread
 
headwinds profile image
brandon flowers

rebuilt eh?

Can you run the app locally in your browser?

Thread Thread
 
josiasaurel profile image
Josias Aurel

Yeah. It works correctly locally

Thread Thread
 
headwinds profile image
brandon flowers

I've pushed my source to github

github.com/headwinds/venv

Thread Thread
 
josiasaurel profile image
Josias Aurel

Thanks. I'll check it

Thread Thread
 
andrewbaisden profile image
Andrew Baisden

Yeah that requirements.txt file is essential without it the routing is broken. As for the problems Josias is having its likely because its Linux and because you are using Termux on Android I think. I don't have any experience with that setup my guess is its something to do with the paths similar to the issues that max had.

Thread Thread
 
headwinds profile image
brandon flowers

github.com/headwinds/venv

clone git@github.com:headwinds/venv.git
cd venv/venv
vercel

Thread Thread
 
josiasaurel profile image
Josias Aurel

Well Andrew you are probably right. Even when I cloned your repo it didn't work for as well. That's probably something with Termux. I am giving up on using only termux and I'll try another way . Thanks guys

Thread Thread
 
josiasaurel profile image
Josias Aurel • Edited

Hey. I gave myself a last try but this time I took away the virtual env. This means that the problem came from he fact that the virtual env replicated my architecture (aarch64) which is not compatible with vercel. I redeployed only with the main server, requirements.txt and the vercel.json config. Here is the basic server running and the
repo

Thread Thread
 
andrewbaisden profile image
Andrew Baisden

Well done you worked hard to find a solution congrats!

Thread Thread
 
josiasaurel profile image
Josias Aurel

Thanks. I am happy it works now

Thread Thread
 
headwinds profile image
brandon flowers

amazing - very happy to hear and also great that you shared your solution for others!