4

I have a webapp that has React frontend with a Flask backend. I want to deploy this application onto a tool called Vercel. Can someone point me to an example tutorial/setup/example Github Repository that accomplishes this task

2 Answers 2

1

As far as I know, you can't deploy the Flask back-end on Vercel. I am not familiar with Flask, but I checked right now and you can deploy your Flask back-end server on railway.app. Then hit from your front-end that you can deploy on Vercel.

Sign up to request clarification or add additional context in comments.

3 Comments

Do you by any chance have an example I can refer to? Is railway.app free?
@karkirsubu Unfortunately, I don't, but the Railway platform is pretty intuitive. Just select the GitHub repo where your server code is and deploy it. Yes, they have a free tier.
thanks. I was able to get railway deploy to work. just a bit of configuration needed to be done.
1

It took me a while to figure this out as well, even though Flask usage is technically "documented" in the official docs. You need something like this:

your_app_root/
└── api/
    ├── function1/
    │   └── index.py
    ├── function2/
    │   └── index.py
    └── index.py

#!index.py
from flask import Flask, Response

app = Flask(__name__)


@app.route("/", defaults={"path": ""})
@app.route("/<path:path>")
def catch_all(path):
    # Everything above this line should look the same for each 
    # index.py. Modify lines below this to have different logic
    # for different routes.
    return Response(
        "<h1>Flask</h1><p>You visited: /%s</p>" % (path), mimetype="text/html"
    )

Basically, each function is going to be a separate Flask app. So you cannot do any routes within the Flask api with @app.route. It needs to all be folder based because Vercel is doing the routing.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.