Update app.py
Browse files
app.py
CHANGED
@@ -8,17 +8,28 @@ app = Flask(__name__, static_folder='.', static_url_path='')
|
|
8 |
def index():
|
9 |
return send_from_directory('.', 'index.html')
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
@app.route('/api/score', methods=['POST'])
|
12 |
def api_score():
|
13 |
-
data
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
combined =
|
19 |
-
|
20 |
-
return jsonify({ **info, "scores": scores })
|
21 |
|
22 |
if __name__ == '__main__':
|
23 |
-
|
24 |
-
app.run(host='0.0.0.0', port=7860, debug=True)
|
|
|
8 |
def index():
|
9 |
return send_from_directory('.', 'index.html')
|
10 |
|
11 |
+
# New endpoint: fetch only metadata once
|
12 |
+
@app.route('/api/meta', methods=['POST'])
|
13 |
+
def api_meta():
|
14 |
+
data = request.get_json(force=True)
|
15 |
+
url = data['url']
|
16 |
+
info = get_youtube_info(url)
|
17 |
+
# Return just title & description
|
18 |
+
return jsonify({
|
19 |
+
"title": info["title"],
|
20 |
+
"description": info["description"]
|
21 |
+
})
|
22 |
+
|
23 |
+
# Score endpoint now expects already-fetched title+description
|
24 |
@app.route('/api/score', methods=['POST'])
|
25 |
def api_score():
|
26 |
+
data = request.get_json(force=True)
|
27 |
+
title = data['title']
|
28 |
+
description = data['description']
|
29 |
+
goal = data.get('goal','')
|
30 |
+
combined = f"{title} {description}"
|
31 |
+
scores = score_fit(combined, goal, method='raw')
|
32 |
+
return jsonify({"scores": scores})
|
|
|
33 |
|
34 |
if __name__ == '__main__':
|
35 |
+
app.run(debug=True)
|
|