Spaces:
Paused
Paused
first
Browse files- .gitignore +136 -0
- Dockerfile +39 -0
- README.md +1 -0
- app.py +10 -0
- nginx.conf +29 -0
- requirements.txt +3 -0
- run.sh +6 -0
- static/index.html +1 -0
.gitignore
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Byte-compiled / optimized / DLL files
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
|
| 6 |
+
# C extensions
|
| 7 |
+
*.so
|
| 8 |
+
|
| 9 |
+
# Distribution / packaging
|
| 10 |
+
.Python
|
| 11 |
+
build/
|
| 12 |
+
develop-eggs/
|
| 13 |
+
dist/
|
| 14 |
+
downloads/
|
| 15 |
+
eggs/
|
| 16 |
+
.eggs/
|
| 17 |
+
lib64/
|
| 18 |
+
parts/
|
| 19 |
+
sdist/
|
| 20 |
+
var/
|
| 21 |
+
wheels/
|
| 22 |
+
pip-wheel-metadata/
|
| 23 |
+
share/python-wheels/
|
| 24 |
+
*.egg-info/
|
| 25 |
+
.installed.cfg
|
| 26 |
+
*.egg
|
| 27 |
+
MANIFEST
|
| 28 |
+
|
| 29 |
+
# PyInstaller
|
| 30 |
+
# Usually these files are written by a python script from a template
|
| 31 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
| 32 |
+
*.manifest
|
| 33 |
+
*.spec
|
| 34 |
+
|
| 35 |
+
# Installer logs
|
| 36 |
+
pip-log.txt
|
| 37 |
+
pip-delete-this-directory.txt
|
| 38 |
+
|
| 39 |
+
# Unit test / coverage reports
|
| 40 |
+
htmlcov/
|
| 41 |
+
.tox/
|
| 42 |
+
.nox/
|
| 43 |
+
.coverage
|
| 44 |
+
.coverage.*
|
| 45 |
+
.cache
|
| 46 |
+
nosetests.xml
|
| 47 |
+
coverage.xml
|
| 48 |
+
*.cover
|
| 49 |
+
*.py,cover
|
| 50 |
+
.hypothesis/
|
| 51 |
+
.pytest_cache/
|
| 52 |
+
|
| 53 |
+
# Translations
|
| 54 |
+
*.mo
|
| 55 |
+
*.pot
|
| 56 |
+
|
| 57 |
+
# Django stuff:
|
| 58 |
+
*.log
|
| 59 |
+
local_settings.py
|
| 60 |
+
db.sqlite3
|
| 61 |
+
db.sqlite3-journal
|
| 62 |
+
|
| 63 |
+
# Flask stuff:
|
| 64 |
+
instance/
|
| 65 |
+
.webassets-cache
|
| 66 |
+
|
| 67 |
+
# Scrapy stuff:
|
| 68 |
+
.scrapy
|
| 69 |
+
|
| 70 |
+
# Sphinx documentation
|
| 71 |
+
docs/_build/
|
| 72 |
+
|
| 73 |
+
# PyBuilder
|
| 74 |
+
target/
|
| 75 |
+
|
| 76 |
+
# Jupyter Notebook
|
| 77 |
+
.ipynb_checkpoints
|
| 78 |
+
|
| 79 |
+
# IPython
|
| 80 |
+
profile_default/
|
| 81 |
+
ipython_config.py
|
| 82 |
+
|
| 83 |
+
# pyenv
|
| 84 |
+
.python-version
|
| 85 |
+
|
| 86 |
+
# pipenv
|
| 87 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
| 88 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
| 89 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
| 90 |
+
# install all needed dependencies.
|
| 91 |
+
#Pipfile.lock
|
| 92 |
+
|
| 93 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
| 94 |
+
__pypackages__/
|
| 95 |
+
|
| 96 |
+
# Celery stuff
|
| 97 |
+
celerybeat-schedule
|
| 98 |
+
celerybeat.pid
|
| 99 |
+
|
| 100 |
+
# SageMath parsed files
|
| 101 |
+
*.sage.py
|
| 102 |
+
|
| 103 |
+
# Environments
|
| 104 |
+
.env
|
| 105 |
+
.venv
|
| 106 |
+
.venv*
|
| 107 |
+
env/
|
| 108 |
+
venv/
|
| 109 |
+
ENV/
|
| 110 |
+
env.bak/
|
| 111 |
+
venv.bak/
|
| 112 |
+
.venv*
|
| 113 |
+
|
| 114 |
+
# Spyder project settings
|
| 115 |
+
.spyderproject
|
| 116 |
+
.spyproject
|
| 117 |
+
|
| 118 |
+
# Rope project settings
|
| 119 |
+
.ropeproject
|
| 120 |
+
|
| 121 |
+
# mkdocs documentation
|
| 122 |
+
/site
|
| 123 |
+
|
| 124 |
+
# mypy
|
| 125 |
+
.mypy_cache/
|
| 126 |
+
.dmypy.json
|
| 127 |
+
dmypy.json
|
| 128 |
+
|
| 129 |
+
# Pyre type checker
|
| 130 |
+
.pyre/
|
| 131 |
+
.vscode/
|
| 132 |
+
.idea/
|
| 133 |
+
|
| 134 |
+
.DS_Store
|
| 135 |
+
|
| 136 |
+
*.pid
|
Dockerfile
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# See https://hub.docker.com/r/nikolaik/python-nodejs
|
| 2 |
+
# https://github.com/nikolaik/docker-python-nodejs
|
| 3 |
+
# Default user is 'pn' with uid 1000, gid 1000
|
| 4 |
+
FROM nikolaik/python-nodejs:python3.10-nodejs18
|
| 5 |
+
|
| 6 |
+
# Install nginx and give permissions to 'pn'
|
| 7 |
+
# See https://www.rockyourcode.com/run-docker-nginx-as-non-root-user/
|
| 8 |
+
USER root
|
| 9 |
+
|
| 10 |
+
RUN apt-get -y update && apt-get -y install nginx
|
| 11 |
+
|
| 12 |
+
RUN mkdir -p /var/cache/nginx \
|
| 13 |
+
/var/log/nginx \
|
| 14 |
+
/var/lib/nginx
|
| 15 |
+
RUN touch /var/run/nginx.pid
|
| 16 |
+
|
| 17 |
+
RUN chown -R pn:pn /var/cache/nginx \
|
| 18 |
+
/var/log/nginx \
|
| 19 |
+
/var/lib/nginx \
|
| 20 |
+
/var/run/nginx.pid
|
| 21 |
+
|
| 22 |
+
# Install dependencies and build app as non-root
|
| 23 |
+
USER pn
|
| 24 |
+
ENV HOME=/home/pn \
|
| 25 |
+
PATH=/home/pn/.local/bin:$PATH
|
| 26 |
+
|
| 27 |
+
RUN mkdir $HOME/app
|
| 28 |
+
|
| 29 |
+
WORKDIR $HOME/app
|
| 30 |
+
|
| 31 |
+
COPY --chown=pn requirements.txt requirements.txt
|
| 32 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 33 |
+
|
| 34 |
+
# Copy nginx configuration
|
| 35 |
+
COPY --chown=pn nginx.conf /etc/nginx/sites-available/default
|
| 36 |
+
|
| 37 |
+
COPY --chown=pn . .
|
| 38 |
+
|
| 39 |
+
CMD ["bash", "run.sh"]
|
README.md
CHANGED
|
@@ -4,6 +4,7 @@ emoji: 🐠
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: purple
|
| 6 |
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
|
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: purple
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 4444
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
app.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def greet(name):
|
| 5 |
+
return "Hello " + name + "!"
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 9 |
+
|
| 10 |
+
demo.launch()
|
nginx.conf
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
server {
|
| 2 |
+
listen 4444 default_server;
|
| 3 |
+
listen [::]:4444 default_server;
|
| 4 |
+
|
| 5 |
+
server_name _;
|
| 6 |
+
|
| 7 |
+
location / {
|
| 8 |
+
# Serve GRADIO 7860
|
| 9 |
+
proxy_pass http://localhost:7860;
|
| 10 |
+
proxy_http_version 1.1;
|
| 11 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 12 |
+
proxy_set_header Connection 'upgrade';
|
| 13 |
+
proxy_set_header Host $host;
|
| 14 |
+
proxy_cache_bypass $http_upgrade;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
location /cheerpj {
|
| 18 |
+
# Serve backend from port 8000
|
| 19 |
+
proxy_pass http://localhost:8080;
|
| 20 |
+
proxy_http_version 1.1;
|
| 21 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 22 |
+
proxy_set_header Connection 'upgrade';
|
| 23 |
+
proxy_set_header Host "localhost:8000";
|
| 24 |
+
proxy_pass_request_headers on;
|
| 25 |
+
|
| 26 |
+
# Disable cache on websockets
|
| 27 |
+
expires -1;
|
| 28 |
+
}
|
| 29 |
+
}
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
uvicorn
|
| 3 |
+
fastapi
|
run.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
python -m http.server 8080 --directory ./static/ & echo $! > http_server.pid
|
| 4 |
+
uvicorn "app:app" --port 7860 --host 0.0.0.0
|
| 5 |
+
pkill -F http_server.pid
|
| 6 |
+
rm http_server.pid
|
static/index.html
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
hello
|