Docfile commited on
Commit
8ba69d1
1 Parent(s): 2b20108

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -3
app.py CHANGED
@@ -5,15 +5,31 @@ from gradio_client import Client, handle_file # Importez gradio_client
5
 
6
  app = Flask(__name__)
7
 
8
- # Configuration de Gemini
9
 
10
- GOOGLE_API_KEY = os.environ.get("TOKEN")
11
 
12
 
 
 
 
 
13
 
14
  @app.route('/')
15
  def index():
16
  return render_template('traduction.html')
17
 
18
 
19
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  app = Flask(__name__)
7
 
 
8
 
 
9
 
10
 
11
+ token = os.environ.get("TOKEN")
12
+
13
+ client = Client("Docfile/Traducteur",hk=token)
14
+
15
 
16
  @app.route('/')
17
  def index():
18
  return render_template('traduction.html')
19
 
20
 
21
+
22
+
23
+ @app.route('/translate', methods=['POST'])
24
+ def translate():
25
+ data = request.get_json()
26
+ input_text = data['input_text']
27
+ source_language = data['source_language']
28
+ target_language = data['target_language']
29
+
30
+ result = client.predict(input_text, source_language, target_language,api_name="/translate")
31
+ print(result)
32
+
33
+ return jsonify({'result': result})
34
+
35
+ # ... autres routes ...