Compare commits

..

No commits in common. "9c26a5610c512246ec8d3429abd5987d27dac788" and "9a60c514c5d43548303013da591b0ce277f01c93" have entirely different histories.

4 changed files with 9 additions and 55 deletions

View File

@ -1,15 +0,0 @@
FROM python:3.11
WORKDIR /app
# apt install
RUN apt-get update && \
DEBAIN_FRONTEND=noninteractive apt-get install -qy libmagic1 libmagic-dev
# other packages if needed
# git openssh-server vim net-tools iputils-ping btop tmux wget
# pip3 install
COPY ./requirements.txt /app/requirements.txt
RUN pip3 install -r /app/requirements.txt
EXPOSE 5000

View File

@ -1,14 +1,10 @@
# Niming Backend Appserver
# Niming Backend
## build
### with docker-compose
See ``docker-compose.yml`` (It is a template)
### Manual
Prepare:
```
apt update
apt install libmagic1 libmagic-dev -y
pip3 install -r requirements.txt
```
@ -17,4 +13,4 @@ Run:
python3 app.py
```
> Shirakami Fubuki is the cutest fox!!!
Shirakami Fubuki is the cutest fox!!!

View File

@ -1,27 +0,0 @@
version: '3'
# template: docker-compose.yml
services:
niming-backend-appserver:
build: .
container_name: niming-backend-appserver
volumes:
- "appserver_data/:/app"
ports:
- "5000:5000"
environment:
- PG_HOST=postgresql+psycopg2://root:password@ip:port/niming_db
- S3_ENDPOINT=ip:port
- S3_ACCESS_KEY=
- S3_SECRET_KEY=
- S3_BUCKET=nmfs
- IGRPC_HOST=ip:port
- PLATFORM_ROOT_PASSWORD=
- JWT_KEY=
- TIMEZONE=Asia/Taipei
restart: unless-stopped
working_dir: /app
command: python3 /app/app.py
#networks:
# - networkName

View File

@ -6,38 +6,38 @@ import grpc
from protobuf_files import igapi_pb2_grpc
from protobuf_files.igapi_pb2 import Request, Reply
IGRPC_HOST = os.getenv("IGRPC_HOST", None)
IGAPI_HOST = os.getenv("IGAPI_HOST", None)
def request_account_info() -> Tuple[dict, int]:
with grpc.insecure_channel(IGRPC_HOST) as channel:
with grpc.insecure_channel(IGAPI_HOST) as channel:
stub = igapi_pb2_grpc.IGAPIStub(channel)
res = stub.account_info(Request())
return dict(res.result.items()), res.err
def request_login() -> Tuple[dict, int]:
with grpc.insecure_channel(IGRPC_HOST) as channel:
with grpc.insecure_channel(IGAPI_HOST) as channel:
stub = igapi_pb2_grpc.IGAPIStub(channel)
res = stub.login(Request())
return dict(res.result.items()), res.err
def request_queue() -> dict:
with grpc.insecure_channel(IGRPC_HOST) as channel:
with grpc.insecure_channel(IGAPI_HOST) as channel:
stub = igapi_pb2_grpc.IGAPIStub(channel)
res = stub.queue(Request())
return dict(res.result.items())
def request_upload(aid:int) -> Tuple[dict, int]:
with grpc.insecure_channel(IGRPC_HOST) as channel:
with grpc.insecure_channel(IGAPI_HOST) as channel:
stub = igapi_pb2_grpc.IGAPIStub(channel)
res = stub.upload(Request(code=aid))
return dict(res.result.items()), res.err
def request_delete(aid:int, code:str) -> Tuple[dict, int]:
with grpc.insecure_channel(IGRPC_HOST) as channel:
with grpc.insecure_channel(IGAPI_HOST) as channel:
stub = igapi_pb2_grpc.IGAPIStub(channel)
res = stub.delete(Request(code=aid, args=[code]))
return dict(res.result.items()), res.err