|
from flask import Flask, request, jsonify, send_from_directory |
|
from youtube_scraper import get_youtube_info |
|
from score_model import score_fit |
|
|
|
app = Flask(__name__, static_folder='.', static_url_path='') |
|
|
|
@app.route('/') |
|
def index(): |
|
return send_from_directory('.', 'index.html') |
|
|
|
@app.route('/api/score', methods=['POST']) |
|
def api_score(): |
|
data = request.get_json(force=True) |
|
url = data['url'] |
|
goal = data.get('goal','') |
|
method = data.get('method','raw') |
|
info = get_youtube_info(url) |
|
combined = f"{info['title']} {info['description']}" |
|
scores = score_fit(combined, goal, method) |
|
return jsonify({ **info, "scores": scores }) |
|
|
|
if __name__ == '__main__': |
|
|
|
app.run(host='0.0.0.0', port=7860, debug=True) |
|
|