我正在使用 Flasksend_file()来让人们从服务器下载文件。
我目前的代码如下:
@app.route('/', methods=["GET", "POST"])
def index():
if request.method == "POST":
link = request.form.get('Link')
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
info_dict = ydl.extract_info(link, download=False)
video_url = info_dict.get("url", None)
video_id = info_dict.get("id", None)
video_title = info_dict.get('title', None)
ydl.download([link])
print("sending file...")
send_file("dl/"+video_title+".f137.mp4", as_attachment=True)
print("file sent, deleting...")
os.remove("dl/"+video_title+".f137.mp4")
print("done.")
return render_template("index.html", message="Success!")
else:
return render_template("index.html", message=message)
Run Code Online (Sandbox Code Playgroud)
我.f137.mp4添加的唯一原因是因为我使用 AWS C9 作为我的在线 IDE,并且我无法安装 FFMPEG 来在 Amazon Linux 上组合音频和视频。然而,这不是问题。问题是它没有发送下载请求。
这是控制台输出:
127.0.0.1 - - [12/Dec/2018 16:17:41] "POST / HTTP/1.1" 200 -
[youtube] 2AYgi2wsdkE: Downloading …Run Code Online (Sandbox Code Playgroud) 我正在处理我的应用程序,并且在添加程序包时我不断收到此错误,因此我可以导入它.
error: type 'Package.Dependency' has no member 'Package'
Run Code Online (Sandbox Code Playgroud)
这是我的Package.swift代码:
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "xHelp",
dependencies: [
.Package(url: "https://github.com/onevcat/Hedwig.git",
majorVersion: 1)
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package …Run Code Online (Sandbox Code Playgroud) 在我正在制作的 Discord Bot 中,它需要从 JSON 文件中选择一个随机对象。我当前的代码是这样的:
function spawn(){
if (randomNum === 24) return
const name = names.randomNum
const embed = new Discord.RichEmbed()
.setTitle(`${name} has been found!`)
.setColor(0x00AE86)
.setThumbnail(`attachment://./sprites/${randomNum}.png`)
.setTimestamp()
.addField("Quick! Capture it with `>capture`!")
msg.channel.send({embed});
}Run Code Online (Sandbox Code Playgroud)
JSON 文件如下所示:
{
"311": "Blargon",
"310": "Xryzoz",
"303": "Noot",
"279": "",
"312": "Arragn",
"35": "Qeud",
...
}Run Code Online (Sandbox Code Playgroud)
我希望它随机选择其中一个,例如303,并将其发布到丰富的嵌入中。从这里我该怎么办?
discord ×1
discord.js ×1
ffmpeg ×1
flask ×1
ios ×1
javascript ×1
node.js ×1
python ×1
swift ×1
youtube-dl ×1