import os from flask import Flask, request, redirect, render_template from huggingface_hub import HfApi app = Flask(__name__) api = HfApi() @app.route('/', methods=['GET', 'POST']) def upload_file(): if request.method == 'POST': file = request.files['file'] repo_id = request.form['repo_id'] revision = request.form['revision'] try: api.upload_file( path_or_file=file, path_in_repo=file.filename, repo_id=repo_id, revision=revision, create_pr=True, ) return f'File {file.filename} uploaded successfully to {repo_id}' except Exception as e: return str(e) return render_template('index.html') if __name__ == '__main__': app.run(debug=True)