soiz1 commited on
Commit
c9fa03d
·
verified ·
1 Parent(s): 2ed3840

Update requirements.txt

Browse files
Files changed (1) hide show
  1. requirements.txt +1 -33
requirements.txt CHANGED
@@ -1,33 +1 @@
1
- from flask import Flask, request, send_file, abort
2
- import requests
3
- import io
4
-
5
- app = Flask(__name__)
6
-
7
- @app.route('/', methods=['GET'])
8
- def download_file():
9
- # クエリパラメータからファイルIDを受け取る
10
- file_id = request.args.get('file_id')
11
- filename = request.args.get('filename', 'downloaded_file')
12
-
13
- if not file_id:
14
- return abort(400, description="file_idパラメータが必要です")
15
-
16
- # Google DriveのダウンロードURL
17
- url = f"https://drive.google.com/uc?export=download&id={file_id}"
18
-
19
- response = requests.get(url)
20
-
21
- if response.status_code == 200:
22
- # レスポンス内容をメモリ上のファイルにする
23
- file_stream = io.BytesIO(response.content)
24
- return send_file(
25
- file_stream,
26
- as_attachment=True,
27
- download_name=filename
28
- )
29
- else:
30
- return abort(response.status_code, description="ファイルの取得に失敗しました")
31
-
32
- if __name__ == '__main__':
33
- app.run(host='0.0.0.0', port=7860, debug=True)
 
1
+ flask