PythonでフレームワークFlaskを使いpipのpytubeの動作をウェブサイト上で実行しようと思うのですがダウンロードボタンを押してもダウンロードが始まりません。解決策をご教授ください。
初心者なので蛇足なコードも多いですが回答お願いします
<!doctype html> <title>サンプル</title> <head> <title></title> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <link rel="stylesheet" type=text/css href="{{ url_for('static', filename='style.css') }}"> <meta http-equiv="X-UA-Compatible" content="IE=edge">Python
1from flask import Flask, render_template 2from pytube import YouTube 3from flask import request 4 5 6 7app = Flask(__name__) 8 9@app.route('/',methods =['POST','GET']) 10def hello(): 11 html = render_template('index.html') 12 return html 13 14@app.route("/send",methods=['POST']) 15def result(): 16 get_value = request.form.getlist("URL") 17 print(get_value) 18 19 yt = YouTube(get_value) 20 21 yt.streams.get_by_itag(137).download(r'c:\test') 22 23 return "ok" 24 25 26if __name__ == "__main__": 27 app.run() 28 29```index.html
</head> <body> <header> <div class="navbar navbar-dark bg-dark box-shadow"> <div class="container d-flex justify-content-between"> <a href="/" class="navbar-brand d-flex align-items-center"> <strong>Youtube Downloader</strong> </a> </div> </div> </header> <div id="container" class="container theme-showcase"> <!-- 検索窓 --> <div class="page-title jumbotron"> <p>ダウンロードしたい動画のURLを入れてください</p> <form id="search" class="search-form corner-all search" method="POST"> <div class="search search-form-content"> <input type="text" id="keyword" class="corner-all form-control search-keyword" placeholder="URL"name="URL"/> </div><meta charset="UTF-8"> <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Cache-Control" content="no-cache"> <meta http-equiv="Expires" content="-1"> <meta name="viewport" content="width=device-width">
<div class="alert"> <span>WARNING</span> We respect the intellectual property rights of others. You may not infringe the copyright, trademark or other proprietary informational rights of any party. <br> </div> <style type="text/css"> /* エラー用 */ div.alert { background-color:#FFEFEF; margin:0 0 1em 0; padding:10px; color:#C25338; border:1px solid #D4440D; line-height:1.5; clear:both; background-repeat:no-repeat; background-position:5px 5px; }</style> </div> <div class="content container"> <h2> </h2><div class="search-form-content"> <form action ="/send" method="POST"> <input type="submit" class="corner-all btn btn-info" value="ダウンロード"/> </form> </div> </form>
</body> </html></div>
![イメージ説明])![イメージ説明](6bb8b4d8ce94b8e1ae5f6282472afbd3.png)
エラーは出ていませんか?出ているなら、出力をコピペして貼ってください
あなたの回答
tips
プレビュー