I started with a full-stack app with Next.js and Typescript frontend and a Python backend. Since we wanted to deploy on Vercel, we migrated all the backend functionality into typescript functions in the /api folder, accessible with:
fetch('api/**foldername**)
The problem is that I have a simple pytorch model so it needs to be Python. I read online that you can have Python serverless vercel functions too.
I need advice on how to make both serverless function types work together.
Here is my folder structure: app/api/routeName/route.ts I tried the same with route.py, but that did not work. I also tried just putting upload.py in the api folder, but that also did not work.
Here is my upload.py file:
from http.server import BaseHTTPRequestHandler
class handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/plain")
self.end_headers()
self.wfile.write("Hello, worldfbgdfgbdfgbd!".encode("utf-8"))
return
very simple just to test connectivity.
I tried using a fetch that console logs the response when a button on the frontend is clicked and goes to localhost:3000/api/update.
There isn't much documentation online, and after looking at some example GitHub repos I'm not sure why my case doesn't work.
Any advice is very much appreciated.