import requests from io import BytesIO from flask import Flask, request, jsonify from gradio_client import Client from huggingface_hub import create_repo, upload_file app = Flask(__name__) @app.route('/faceswapper', methods=['POST']) def faceswapper(): # Obter parĂ¢metros da consulta da URL endpoint = request.args.get('endpoint', default='https://pierroromeu-faceswapper.hf.space/--replicas/u42x7/') user_photo = request.args.get('user_photo', default='') result_photo = request.args.get('result_photo', default='') # Chamar a API Gradio client = Client(endpoint, upload_files=True) result = client.predict( user_photo, result_photo, api_name="/predict" ) return jsonify(result) if __name__ == "__main__": app.run(host="0.0.0.0", port=7860)