Spaces:
Sleeping
Sleeping
Evilmass
commited on
Commit
·
5bcd0e8
1
Parent(s):
ef98279
Add application file
Browse files- Dockerfile +16 -0
- app.py +48 -0
- requirements.txt +3 -0
Dockerfile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
| 2 |
+
# you will also find guides on how best to write your Dockerfile
|
| 3 |
+
|
| 4 |
+
FROM python:3.9
|
| 5 |
+
|
| 6 |
+
RUN useradd -m -u 1000 user
|
| 7 |
+
USER user
|
| 8 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 9 |
+
|
| 10 |
+
WORKDIR /app
|
| 11 |
+
|
| 12 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
| 13 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 14 |
+
|
| 15 |
+
COPY --chown=user . /app
|
| 16 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import uvicorn
|
| 2 |
+
from fastapi import FastAPI
|
| 3 |
+
from pydantic import BaseModel
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class SystemInfo(BaseModel):
|
| 9 |
+
json_ver: str
|
| 10 |
+
title: str
|
| 11 |
+
revision: str
|
| 12 |
+
api_timeout: int
|
| 13 |
+
mtm: str
|
| 14 |
+
mtms: str
|
| 15 |
+
mmr: str
|
| 16 |
+
tmr: str
|
| 17 |
+
nkm: str
|
| 18 |
+
wlt: str
|
| 19 |
+
selector: str
|
| 20 |
+
working_state: str
|
| 21 |
+
custom_property: str
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
@app.get("/systems/EAR-B-WW/00001/system.json", response_model=SystemInfo)
|
| 25 |
+
async def read_system_info():
|
| 26 |
+
return SystemInfo(
|
| 27 |
+
json_ver="1.0.2",
|
| 28 |
+
title="EAR-B-WW",
|
| 29 |
+
revision="00001",
|
| 30 |
+
api_timeout=30000,
|
| 31 |
+
mtm="https://server.mhwee.com",
|
| 32 |
+
mtms="https://mtms.rebe.capcom.com",
|
| 33 |
+
mmr="https://mmr.rebe.capcom.com",
|
| 34 |
+
tmr="https://server.mhwee.com/v1/projects/earth-analysis-obt/topics/analysis-client-log:publish",
|
| 35 |
+
nkm="https://nkm.rebe.capcom.com",
|
| 36 |
+
wlt="https://wlt.rebe.capcom.com",
|
| 37 |
+
selector="https://selector.gs.capcom.com",
|
| 38 |
+
working_state="alive",
|
| 39 |
+
custom_property="eyJvYnRfaW5mbyI6eyJlbnYiOjEsInN0YXJ0X3RpbWUiOjE3MzA0MjgyMDAsImVuZF90aW1lIjoxNzMwOTg5MjAwfSwicWEzIjp7ImFwaSI6Imh0dHBzOi8vc2VydmVyLm1od2VlLmNvbSIsIm5vdGlmeSI6IndzczovL3NlcnZlci5taHdlZS5jb20ifX0=",
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
if __name__ == "__main__":
|
| 44 |
+
# uvicorn.run(app, host="0.0.0.0")
|
| 45 |
+
uvicorn.run(app, host="0.0.0.0", port=443, ssl_certfile="cert.pem", ssl_keyfile="key.pem")
|
| 46 |
+
|
| 47 |
+
# gunicorn --certfile=cert.pem --keyfile=key.pem --bind 0.0.0.0:443 app:app
|
| 48 |
+
# uvicorn main:app --host 0.0.0.0 --port 443 --ssl-certfile cert.pem --ssl-keyfile key.pem
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
pydantic
|
| 3 |
+
uvicorn[standard]
|