freemt commited on
Commit
679a546
·
1 Parent(s): e66eeb8

Update app.py

Browse files
Files changed (7) hide show
  1. .stignore +101 -0
  2. app.py +37 -0
  3. install-sw.sh +23 -0
  4. install-sw1.sh +25 -0
  5. okteto-up.bat +1 -0
  6. okteto.yml +44 -0
  7. requirements.txt +4 -0
.stignore ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .git
2
+ # Byte-compiled / optimized / DLL files
3
+ __pycache__
4
+ *.py[cod]
5
+ *$py.class
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build
13
+ develop-eggs
14
+ dist
15
+ downloads
16
+ eggs
17
+ .eggs
18
+ lib
19
+ lib64
20
+ parts
21
+ sdist
22
+ var
23
+ wheels
24
+ pip-wheel-metadata
25
+ share/python-wheels
26
+ *.egg-info
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Translations
42
+ *.mo
43
+ *.pot
44
+
45
+ # Django stuff:
46
+ *.log
47
+ local_settings.py
48
+ db.sqlite3
49
+
50
+ # Flask stuff:
51
+ instance
52
+ .webassets-cache
53
+
54
+ # Scrapy stuff:
55
+ .scrapy
56
+
57
+ # Sphinx documentation
58
+ docs/_build
59
+
60
+ # PyBuilder
61
+ target
62
+
63
+ # Jupyter Notebook
64
+ .ipynb_checkpoints
65
+
66
+ # IPython
67
+ profile_default
68
+ ipython_config.py
69
+
70
+ # pyenv
71
+ .python-version
72
+
73
+ # celery beat schedule file
74
+ celerybeat-schedule
75
+
76
+ # SageMath parsed files
77
+ *.sage.py
78
+
79
+ # Environments
80
+ .env
81
+ .venv
82
+ env
83
+ venv
84
+ ENV
85
+ env.bak
86
+ venv.bak
87
+
88
+ # Spyder project settings
89
+ .spyderproject
90
+ .spyproject
91
+
92
+ # Rope project settings
93
+ .ropeproject
94
+
95
+ # mypy
96
+ .mypy_cache
97
+ .dmypy.json
98
+ dmypy.json
99
+
100
+ # Pyre type checker
101
+ .pyre
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import multiprocessing
2
+ import gradio as gr
3
+ import httpx
4
+ from logzero import logger
5
+ from deepl_fastapi.run_uvicorn import main
6
+
7
+ multiprocessing.Process(target=main).start()
8
+
9
+
10
+ def deepl(text, from_lang, to_lang):
11
+ # "http://127.0.0.1:8000/text/?q=test%20me&to_lang=zh"
12
+ url = "http://127.0.0.1:8000/text/" # ?q=test%20me&to_lang=zh"
13
+ try:
14
+ resp = httpx.get(f"{url}?q={text}&from_lang={from_lang}&to_lang={to_lang}")
15
+ resp.raise_for_status()
16
+ except Exception as exc:
17
+ logger.error(exc)
18
+ return str(exc)
19
+ try:
20
+ jdata = resp.json()
21
+ except Exception as exc:
22
+ logger.error(exc)
23
+ return str(exc)
24
+
25
+ return jdata.get("trtext")
26
+
27
+
28
+ iface = gr.Interface(
29
+ fn=deepl,
30
+ inputs=[
31
+ gr.Textbox(placeholder="Paste text here (max. 5000 chars)", lines=7,),
32
+ gr.Textbox(label="from_lang", value="en", lines=1),
33
+ gr.Textbox(label="to_lang", value="zh", lines=1),
34
+ ],
35
+ outputs="textarea"
36
+ )
37
+ iface.launch()
install-sw.sh ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # pip install pipx
2
+ # pipx install poetry
3
+ # pipx ensurepath
4
+ # source ~/.bashrc
5
+
6
+ # curl -sSL https://install.python-poetry.org | python3 -
7
+ # -C- continue -S show error -o output
8
+ curl -sSL -C- -o install-poetry.py https://install.python-poetry.org
9
+ python install-poetry.py
10
+ rm install-poetry.py
11
+ echo export PATH=~/.local/bin:$PATH > ~/.bashrc
12
+ source ~/.bashrc
13
+ # ~/.local/bin/poetry install
14
+
15
+ wget -c https://deb.nodesource.com/setup_14.x
16
+ bash setup_14.x
17
+ apt-get install -y nodejs
18
+ npm install -g npm@latest
19
+ npm install -g nodemon
20
+ rm setup_14.x
21
+
22
+ # apt upate # alerady done in apt-get install -y nodejs
23
+ apt install byobu -y > /dev/null 2>&1
install-sw1.sh ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # pip install pipx
2
+ # pipx install poetry
3
+ # pipx ensurepath
4
+ # source ~/.bashrc
5
+
6
+ # curl -sSL https://install.python-poetry.org | python3 -
7
+ # -C- continue -S show error -o output
8
+ curl -sSL -C- -o install-poetry.py https://install.python-poetry.org
9
+ python install-poetry.py
10
+ rm install-poetry.py
11
+ echo export PATH=~/.local/bin:$PATH > ~/.bashrc
12
+ source ~/.bashrc
13
+ # ~/.local/bin/poetry install
14
+
15
+ wget -c https://deb.nodesource.com/setup_12.x
16
+ bash setup_12.x
17
+ apt-get install -y nodejs
18
+ npm install -g npm@latest
19
+ npm install -g nodemon
20
+ rm setup_12.x
21
+
22
+ # apt update # alerady done in apt-get install -y nodejs
23
+ apt install byobu -y > /dev/null 2>&1
24
+ byobu-enable
25
+ byobu
okteto-up.bat ADDED
@@ -0,0 +1 @@
 
 
1
+ okteto up
okteto.yml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: gradio-cmat
2
+
3
+ # The build section defines how to build the images of
4
+ # your development environment
5
+ # More info: https://www.okteto.com/docs/reference/manifest/#build
6
+ # build:
7
+ # my-service:
8
+ # context: .
9
+
10
+ # The deploy section defines how to deploy your development environment
11
+ # More info: https://www.okteto.com/docs/reference/manifest/#deploy
12
+ # deploy:
13
+ # commands:
14
+ # - name: Deploy
15
+ # command: echo 'Replace this line with the proper 'helm'
16
+
17
+ # or 'kubectl' commands to deploy your development environment'
18
+
19
+ # The dependencies section defines other git repositories to be
20
+ # deployed as part of your development environment
21
+ # More info: https://www.okteto.com/docs/reference/manifest/#dependencies
22
+ # dependencies:
23
+ # - https://github.com/okteto/sample
24
+ # The dev section defines how to activate a development container
25
+ # More info: https://www.okteto.com/docs/reference/manifest/#dev
26
+ dev:
27
+ gradio-cmat:
28
+ # image: okteto/dev:latest
29
+ # image: python:3.8.13-bullseye
30
+ # image: simbachain/poetry-3.8
31
+ image: python:3.8
32
+ command: bash
33
+ workdir: /usr/src/app
34
+ sync:
35
+ - .:/usr/src/app
36
+ environment:
37
+ - name=$USER
38
+ forward:
39
+ - 7861:7861
40
+ - 7860:7860
41
+ - 8501:8501
42
+ reverse:
43
+ - 9000:9000
44
+ autocreate: true
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ deepl-fastapi
2
+ logzero
3
+ httpx
4
+ jinja2