A simple web application demo of Python Flask hosted on free plan (hobby) on Vercel Serverless Functions. Demo can be seen at https://flask.lhotak.net/ and https://flask.lhotak.net/heartbeat
- If you want to use Vercel for hosting your production using a hobby plan be aware of certain limitations.
- Vercel currently supports (only) Python 3.9 released back in 2020 see doc
- Vercel Serverless Functions is primarily built for Type Script web apps, don't expect much Python support
- In addition to the serverless functions Vercel platform a couple of serverless storage products:
- Vercel KV: Durable Redis - preferred option of key-value data
- Vercel Postgres: Serverless SQL - preferred option when relation database is required
- Vercel Blob: Large file storage
- Vercel Edge Config: Global, low-latency data store
- But it's free, so why not to try it out?
- CORS - handling Cross Origin Resource Sharing
- Whitenoise - simplified static file serving without relying on Nginx
Ubuntu 22.04 and Python
sudo apt-get install -y -q python3 python3-setuptools python3-dev build-essential
Install Python Flask dependency
pip install -r ./requirements.txt
- Copy app.py or download it from source repository
Start web server
FLASK_APP=app.py flask run --host=0.0.0.0
Open a browser and go to URL
http://<IP>:5000/ => Hello world
http://<IP>:5000/heartbeat => ok