Deploy Flask for free with Vercel

Deploy Flask for free with Vercel

Let's say you have built a flask app and want to deploy it for free. Even though there are other options such as Heroku, depends your case, Vercel could be a simple and great option.

What's Vercel?

Vercel is an open serverless platform for static and hybrid applications. It's well know mainly for react and next.js developers.

Disclaimer

I'm not saying it's the best option for your case, however, I was impressed how quick I did my first Flask deploy to it. Keep reading to see where I found the limitations.

Requirements

The very basic Flask App up running

Basically you'll need 3 files and 1 command:

flask-vercel
  .
  โ”œโ”€โ”€ index.py
  โ”œโ”€โ”€ requirements.txt
  โ””โ”€โ”€ vercel.json

v1_vercel_files.png

Then, running the command vercel inside the project root folder and answering few question, you should get your app up running

v1_cmd_print.png

Check my flask-vercel github repository out to find out the source code and more details such as how run it locally before ship it.

Important:

  • As a didactic purpose, the v1 tag (the code above) shows the fastest and simple way to deploy it, however, so far this won't be a real Flask project. You might need a structured project, a bunch of dependencies and soon.
  • In the v2 I've added OpenAPI, config, a better structure, pytest and a database. However, I did have trouble using the migrations, in another words, where should I run the flask db upgrade to run the database migrations in order to add new tables and fields for my application? Probably, this is the limitation of a "serverless platform", right?
  • I might post something regarding this point soon, few free to get in touch, contribute or give your point about Vercel and Flask, the code it self or whatever you want to.

Cheers!

Links:

ย