我已经构建了一个简单的Web应用程序,该应用程序可以在localhost上完美运行,但是现在我试图在Internet上获取它,但遇到500错误。
import os
from flask import Flask, render_template, redirect, request, send_file
from validator import validator, generate_token
app = Flask(__name__)
@app.route("/",methods=["GET","POST"])
def hello():
try:
if request.method == "POST":
uri = request.form['uri']
id = validator(uri)
if id != 0:
token = generate_token()
command = './script.sh ' + id + ' ' + token
os.system(command)
return redirect("/download/" + token, code=302)
except as e:
print(e)
return render_template("index.html")
@app.route("/download/<token>")
def download(token):
return send_file(f'../songs/{token}.zip', cache_timeout=-1)
if __name__ == "__main__":
app.run()
当我尝试使用
在服务器中运行.py文件时python3 __init__.py
它给了我以下错误:
File "__init__.py", line 24
return send_file(f'../songs/{token}.zip', cache_timeout=-1)
有什么提示吗?