-
Notifications
You must be signed in to change notification settings - Fork 0
/
uploading_file.py
30 lines (24 loc) · 1000 Bytes
/
uploading_file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from flask import Flask, request, jsonify
import os
app = Flask(__name__)
UPLOAD_FOLDER = 'videos'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
def run_script(video_path):
# Write your Python script here
# For demonstration, let's assume we're just printing the video path
print("Processing video:", video_path)
@app.route('/upload', methods=['POST'])
def upload_file():
if 'file' not in request.files:
return jsonify({'error': 'No file part'})
file = request.files['file']
if file.filename == '':
return jsonify({'error': 'No selected file'})
if file:
filename = file.filename
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
video_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
run_script(video_path) # Run your Python script on the uploaded file
return jsonify({'message': 'File uploaded successfully', 'filename': filename})
if __name__ == '__main__':
app.run(debug=True)