【发布时间】:2020-06-21 21:58:25
【问题描述】:
我目前有一个带有 python api 后端的 Nextjs 应用程序。我遇到的问题是 Vercel 有 24 个无服务器功能的限制,他们似乎建议应该结合您的无服务器功能来“优化”您的功能并避免冷启动。
目前我有以下代码
from sanic import Sanic
from sanic.response import json
app = Sanic()
@app.route('/')
@app.route('/<path:path>')
async def index(request, path=""):
return json({'hello': path})
@app.route('/other_route')
async def other_route(request, path=""):
return json({'whatever': path})
但是,当我点击 api/other_route 时,我得到了 404。我知道我可以创建名为 other_route.py 的单独文件但我想知道是否有办法在我的 index.py 路由中组合该路由以避免创建另一个无服务器功能。
【问题讨论】:
标签: python flask next.js vercel sanic