camilosegura commited on
Commit
53d152d
1 Parent(s): 0afa9de

Upload folder using huggingface_hub

Browse files
Files changed (7) hide show
  1. README.md +2 -2
  2. app.py +9 -4
  3. src/.env +4 -0
  4. src/.gitignore +2 -1
  5. src/demo/app.py +9 -4
  6. src/pyproject.toml +1 -1
  7. src/requirements.txt +1 -0
README.md CHANGED
@@ -2,8 +2,8 @@
2
  ---
3
  tags: [gradio-custom-component, gradio-template-SimpleTextbox]
4
  title: gradio_keyboardtextboxcomponent V0.0.1
5
- colorFrom: red
6
- colorTo: gray
7
  sdk: docker
8
  pinned: false
9
  license: apache-2.0
 
2
  ---
3
  tags: [gradio-custom-component, gradio-template-SimpleTextbox]
4
  title: gradio_keyboardtextboxcomponent V0.0.1
5
+ colorFrom: yellow
6
+ colorTo: pink
7
  sdk: docker
8
  pinned: false
9
  license: apache-2.0
app.py CHANGED
@@ -3,9 +3,14 @@ import gradio as gr
3
  from gradio_keyboardtextboxcomponent import KeyboardTextBoxComponent
4
  import json
5
  import requests
 
 
6
 
7
- API_URL_LIST = "https://2xp1wr4k54.execute-api.us-east-1.amazonaws.com/dev/v1/translations/index"
8
- API_URL_UPDATE = "https://2xp1wr4k54.execute-api.us-east-1.amazonaws.com/dev/v1/translations/update"
 
 
 
9
 
10
  # Una aplicación con un listado de traducciones pendientes
11
  # presionar sobre una
@@ -21,7 +26,7 @@ request = {
21
  "per_page": 10
22
  }
23
  }
24
- translations_response = requests.post(API_URL_LIST, json=request)
25
  #json.loads(str(response["Item"]).replace("'", '"').encode('utf-8'))
26
  translations_response=json.loads(json.dumps(translations_response.json()).replace("'", '"').encode('utf-8'))["records"]
27
  translations = list(map(lambda x: [f'{x["gum"]} : {x["es"]}', x["gum"], x["es"], x["translation_timestamp"]], translations_response))
@@ -45,7 +50,7 @@ def translation_chat_fn(translation_index, mod_gum, mod_spa):
45
  }
46
  }
47
  }
48
- response = requests.post(API_URL_UPDATE, json=request)
49
  response.json()
50
 
51
  return "Traducción corregida" if response.status_code == 200 else "Error del servicio"
 
3
  from gradio_keyboardtextboxcomponent import KeyboardTextBoxComponent
4
  import json
5
  import requests
6
+ import os
7
+ from dotenv import load_dotenv
8
 
9
+ load_dotenv()
10
+
11
+ API_URL_LIST = os.getenv('API_URL_LIST')
12
+ API_URL_UPDATE = os.getenv('API_URL_UPDATE')
13
+ API_TOKEN = os.getenv('API_TOKEN')
14
 
15
  # Una aplicación con un listado de traducciones pendientes
16
  # presionar sobre una
 
26
  "per_page": 10
27
  }
28
  }
29
+ translations_response = requests.post(API_URL_LIST, json=request, headers={"x-api-key":API_TOKEN})
30
  #json.loads(str(response["Item"]).replace("'", '"').encode('utf-8'))
31
  translations_response=json.loads(json.dumps(translations_response.json()).replace("'", '"').encode('utf-8'))["records"]
32
  translations = list(map(lambda x: [f'{x["gum"]} : {x["es"]}', x["gum"], x["es"], x["translation_timestamp"]], translations_response))
 
50
  }
51
  }
52
  }
53
+ response = requests.post(API_URL_UPDATE, json=request, headers={"x-api-key":API_TOKEN})
54
  response.json()
55
 
56
  return "Traducción corregida" if response.status_code == 200 else "Error del servicio"
src/.env ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ API_URL_LIST="https://yx17nv2k69.execute-api.us-east-1.amazonaws.com/dev/v1/translations/index"
2
+ API_URL_UPDATE="https://yx17nv2k69.execute-api.us-east-1.amazonaws.com/dev/v1/translations/update"
3
+ API_URL_CREATE="https://yx17nv2k69.execute-api.us-east-1.amazonaws.com/dev/v1/translations/create"
4
+ API_TOKEN="JXw9rVx7eY7S63Bv4wAth45ZwQ4j0Tn082zansPh"
src/.gitignore CHANGED
@@ -6,4 +6,5 @@ __pycache__/
6
  *$py.class
7
  __tmp/*
8
  *.pyi
9
- node_modules
 
 
6
  *$py.class
7
  __tmp/*
8
  *.pyi
9
+ node_modules
10
+ .env
src/demo/app.py CHANGED
@@ -3,9 +3,14 @@ import gradio as gr
3
  from gradio_keyboardtextboxcomponent import KeyboardTextBoxComponent
4
  import json
5
  import requests
 
 
6
 
7
- API_URL_LIST = "https://2xp1wr4k54.execute-api.us-east-1.amazonaws.com/dev/v1/translations/index"
8
- API_URL_UPDATE = "https://2xp1wr4k54.execute-api.us-east-1.amazonaws.com/dev/v1/translations/update"
 
 
 
9
 
10
  # Una aplicación con un listado de traducciones pendientes
11
  # presionar sobre una
@@ -21,7 +26,7 @@ request = {
21
  "per_page": 10
22
  }
23
  }
24
- translations_response = requests.post(API_URL_LIST, json=request)
25
  #json.loads(str(response["Item"]).replace("'", '"').encode('utf-8'))
26
  translations_response=json.loads(json.dumps(translations_response.json()).replace("'", '"').encode('utf-8'))["records"]
27
  translations = list(map(lambda x: [f'{x["gum"]} : {x["es"]}', x["gum"], x["es"], x["translation_timestamp"]], translations_response))
@@ -45,7 +50,7 @@ def translation_chat_fn(translation_index, mod_gum, mod_spa):
45
  }
46
  }
47
  }
48
- response = requests.post(API_URL_UPDATE, json=request)
49
  response.json()
50
 
51
  return "Traducción corregida" if response.status_code == 200 else "Error del servicio"
 
3
  from gradio_keyboardtextboxcomponent import KeyboardTextBoxComponent
4
  import json
5
  import requests
6
+ import os
7
+ from dotenv import load_dotenv
8
 
9
+ load_dotenv()
10
+
11
+ API_URL_LIST = os.getenv('API_URL_LIST')
12
+ API_URL_UPDATE = os.getenv('API_URL_UPDATE')
13
+ API_TOKEN = os.getenv('API_TOKEN')
14
 
15
  # Una aplicación con un listado de traducciones pendientes
16
  # presionar sobre una
 
26
  "per_page": 10
27
  }
28
  }
29
+ translations_response = requests.post(API_URL_LIST, json=request, headers={"x-api-key":API_TOKEN})
30
  #json.loads(str(response["Item"]).replace("'", '"').encode('utf-8'))
31
  translations_response=json.loads(json.dumps(translations_response.json()).replace("'", '"').encode('utf-8'))["records"]
32
  translations = list(map(lambda x: [f'{x["gum"]} : {x["es"]}', x["gum"], x["es"], x["translation_timestamp"]], translations_response))
 
50
  }
51
  }
52
  }
53
+ response = requests.post(API_URL_UPDATE, json=request, headers={"x-api-key":API_TOKEN})
54
  response.json()
55
 
56
  return "Traducción corregida" if response.status_code == 200 else "Error del servicio"
src/pyproject.toml CHANGED
@@ -43,7 +43,7 @@ classifiers = [
43
  dev = ["build", "twine"]
44
 
45
  [tool.hatch.build]
46
- artifacts = ["/backend/gradio_keyboardtextboxcomponent/templates", "*.pyi", "backend/gradio_keyboardtextboxcomponent/templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates"]
47
 
48
  [tool.hatch.build.targets.wheel]
49
  packages = ["/backend/gradio_keyboardtextboxcomponent"]
 
43
  dev = ["build", "twine"]
44
 
45
  [tool.hatch.build]
46
+ artifacts = ["/backend/gradio_keyboardtextboxcomponent/templates", "*.pyi", "backend/gradio_keyboardtextboxcomponent/templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates", "\\backend\\gradio_keyboardtextboxcomponent\\templates"]
47
 
48
  [tool.hatch.build.targets.wheel]
49
  packages = ["/backend/gradio_keyboardtextboxcomponent"]
src/requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  requests
2
  gradio
 
 
1
  requests
2
  gradio
3
+ load_dotenv