vercel

170 views
Skip to first unread message

stifan kristi

unread,
Nov 30, 2021, 5:57:38 AM11/30/21
to py4web
perhaps any hints to deploy py4web on vercel?

ref :

https://dev.to/yash_makan/4-best-python-web-app-hosting-services-for-freewith-complete-process-57nb

thanks and best regards,
stifan

Val K

unread,
Nov 30, 2021, 9:49:41 AM11/30/21
to py4web
"use": "@vercel/python" (instead of unexplained "@liudonghua123/now-flask" )

#app.py
from py4web.core import wsgi

app = wsgi(apps_folder="apps", "password_file"="...", <the same as cli args>)

should work
вторник, 30 ноября 2021 г. в 13:57:38 UTC+3, stifan kristi:

stifan kristi

unread,
Dec 1, 2021, 6:17:36 AM12/1/21
to py4web
thanks, it works well, here is the full step
note : _dashboard and _default is not work (on local dev and vercel.com), perhaps some hints to make _dashboard works

pip install -U py4web
npm i vercel
mkdir py4web
cd py4web
py4web setup apps
py4web set_password
cat << EOF > vercel.json
{
  "version": 0,
  "builds": [
      {
          "src": "*.py",
          "use": "@vercel/python"
      }
  ],
  "routes": [
      {
          "src": "(.*)",
          "dest": "app.py"
      }
  ]
}
EOF
cat << EOF > requirements.txt
py4web
EOF
cat << EOF > app.py
from py4web.core import wsgi
app = wsgi(apps_folder = "apps", password_file = "password.txt")
EOF
../node_modules/.bin/vercel dev
../node_modules/.bin/vercel

best regards,
stifan

Val K

unread,
Dec 1, 2021, 7:01:03 AM12/1/21
to py4web
add dashboard_mode='full' to wsgi-args
also don't forget to run py4web to set password on you local machine before deploy


среда, 1 декабря 2021 г. в 14:17:36 UTC+3, stifan kristi:

Val K

unread,
Dec 1, 2021, 7:08:36 AM12/1/21
to py4web
The _default app is now only registered as the root app, i.e. no _default / * routes, but only / * routes

среда, 1 декабря 2021 г. в 14:17:36 UTC+3, stifan kristi:
thanks, it works well, here is the full step

stifan kristi

unread,
Dec 1, 2021, 1:33:00 PM12/1/21
to py4web
thanks for explain it, tested work well, here the modify part that make _dashboard works on vercel

cat << EOF > app.py
from py4web.core import wsgi
app = wsgi(apps_folder = "apps", password_file = "password.txt", dashboard_mode = "full")
EOF

best regards,
stifan
Message has been deleted

Jarvis Silva

unread,
Nov 1, 2023, 5:35:28 AM11/1/23
to py4web

Now you can host a flask app on vercel using their serveless functions, they have a python runtime, in your code you need to create a vercel.json file and add the python api routes and also add all the python code inside a api folder.

here is a complete step by step tutorial on how to do it: Deploy flask app to vercel

Reply all
Reply to author
Forward
0 new messages