lijunyi2
(AJiaBoKe)
July 30, 2024, 8:00am
1
My app.py is just a simple Python program, vercel console node version I set to 18x, and then my vercel.json configuration is as follows, when I deploy, prompt picture error. How do I solve it?
my vercel.json
{
"version": 2,
"functions": {
"app.py": {
"runtime": "vercel-python@3.9" , // or vercel-python@3.12
"maxDuration": 30,
"memory": 1024
}
},
"routes": [
{
"src": "/(.*)",
"dest": "/app.py"
}
]
}
pawlean
(Pauline P. Narvas)
July 30, 2024, 9:34am
3
Hi, @lijunyi2 !
Welcome to the Vercel Community
I don’t see any issues with your vercel.json
file. Do you have any other configuration files e.g. requirements.txt
?
Some things I would try:
Removing the runtime on your .json
all together. You don’t necessarily need to specify the version as by default, new projects will use the latest Python version available on Vercel.
Specifying the version in a Pipfile
. From the relevant documentation :
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
flask = "*"
[requires]
python_version = "3.12"
I’ll also leave some examples of some Python projects that might be helpful to look at.
1 Like
lijunyi2
(AJiaBoKe)
July 31, 2024, 12:46am
4
My requirements.txt
content is as follows:
Flask==3.0.3
Flask-Cors==3.0.10
gunicorn==20.1.0
my app.py
content is as follows:
from flask import Flask, request, jsonify
from flask_cors import CORS
import poplib
from email.parser import BytesParser
import re
import time
app = Flask(__name__)
CORS(app)
@app.route('/', methods=['POST'])
def home():
return jsonify({"msg": "test",
"data": "test"}), 200
The structure of my project is as follows:
So how can I modify my configuration to solve this deployment problem?
lijunyi2
(AJiaBoKe)
July 31, 2024, 3:06am
5
I solved it myself, thank you.
pawlean
(Pauline P. Narvas)
July 31, 2024, 8:18am
6
Great to hear, @lijunyi2 ! Could you share your solution?
lijunyi2
(AJiaBoKe)
August 1, 2024, 1:52am
7
The file directory is like this:
the vercel.json
is like this:
{
"rewrites": [
{ "source": "/(.*)", "destination": "/api/index" }
],
"functions": {
"api/*.py": {
"maxDuration": 60
}
}
}
/api/index
, index
is your file name。
I solved the python project, but the nodejs project is different from this. Do you have an example of how to set maxDuration in nodejs?
system
(system)
Closed
August 2, 2024, 1:52am
8
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.