craftgamesnetwork commited on
Commit
783f9ad
·
verified ·
1 Parent(s): 35fa2b6

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +17 -1
main.py CHANGED
@@ -6,6 +6,16 @@ from huggingface_hub import create_repo, upload_file
6
 
7
  app = Flask(__name__)
8
 
 
 
 
 
 
 
 
 
 
 
9
  @app.route('/run', methods=['POST'])
10
  def run_model():
11
  # Obter parâmetros da consulta da URL
@@ -92,7 +102,13 @@ def faceswapper():
92
  api_name="/predict"
93
  )
94
 
95
- return jsonify(result)
 
 
 
 
 
 
96
 
97
  @app.route('/train', methods=['POST'])
98
  def answer():
 
6
 
7
  app = Flask(__name__)
8
 
9
+ # Função para chamar a API de hospedagem de imagens
10
+ def host_image(image_path):
11
+ api_url = "https://wosocial.bubbleapps.io/version-test/api/1.1/wf/save"
12
+ files = {'file': open(image_path, 'rb')}
13
+ response = requests.post(api_url, files=files)
14
+ if response.status_code == 200:
15
+ return response.json()["response"]["result"]
16
+ else:
17
+ return None
18
+
19
  @app.route('/run', methods=['POST'])
20
  def run_model():
21
  # Obter parâmetros da consulta da URL
 
102
  api_name="/predict"
103
  )
104
 
105
+ # Hospedar a imagem e obter a URL
106
+ hosted_url = host_image(result_path)
107
+
108
+ if hosted_url:
109
+ return jsonify({"result_url": hosted_url})
110
+ else:
111
+ return jsonify({"error": "Falha ao hospedar a imagem."}), 500
112
 
113
  @app.route('/train', methods=['POST'])
114
  def answer():