我想在用户单击HTML表单按钮时执行python代码。怎么可能呢?用户是否可能无法在服务器上查看python代码?表单输入将成为python代码中的变量。我使用的是Flask框架和python2.7。安全还不是个问题。在
我的路径.py文件:
from pytube import YouTube
from moviepy.editor import *
import os
app = Flask(__name__)
@app.route("/",methods=['GET','POST'])
def landing():
return render_template("index.html",ytdir=ytdir,ytlink=ytlink)
if __name__ == "__main__":
app.run(debug=True)
在索引.html在模板文件夹中:
^{pr2}$基本上,我有一个python代码,通过使用ytdir
和ytlink
将YouTube视频下载到本地驱动器中。在
我应该将python代码放在哪里,以便在单击按钮时执行它。在
我建议你做一个“api调用”
在javascript中,使用axios或其他东西使用jquery下载文件 像
$button.click(() => axios.get(http://<localhost url>:<port>/ytdl)
再去读一遍文档如何做ajax调用相关问题 更多 >
编程相关推荐