25.09.08
parent
d78476e78a
commit
39512df5de
16
Dockerfile.1
16
Dockerfile.1
|
@ -1,16 +0,0 @@
|
||||||
FROM python:3.12-slim
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY requirements.txt .
|
|
||||||
|
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
EXPOSE 8000
|
|
||||||
|
|
||||||
# CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
||||||
|
|
||||||
# CMD ["gunicorn", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:8000", "main:app"]
|
|
||||||
CMD ["gunicorn", "--config", "gunicorn.conf.py", "main:app"]
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
MIT License Copyright (c) 2025 xinac.com
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is furnished
|
||||||
|
to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice (including the next
|
||||||
|
paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||||
|
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||||
|
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
45
README.md
45
README.md
|
@ -1,27 +1,32 @@
|
||||||
# api_favicon
|
# favicon-api-v3
|
||||||
|
|
||||||
|
### 接口简介
|
||||||
|
|
||||||
- https://api.xinac.net/
|
- https://api.xinac.net/
|
||||||
|
|
||||||
> python3 -m pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
|
### 接口演示
|
||||||
|
|
||||||
- 启动方式:
|
- https://api.xinac.net/icon/
|
||||||
|
|
||||||
python3 main.py 或 uwsgi --ini uwsgi.ini
|
|
||||||
|
|
||||||
- API使用
|
### 使用方式
|
||||||
|
|
||||||
|
1. python3 -m pip install -r requirements.txt
|
||||||
|
2. python3 run.py
|
||||||
|
|
||||||
|
### 生产使用
|
||||||
|
|
||||||
|
1. python3 -m pip install -r requirements.txt
|
||||||
|
2. chmod +x startup.sh && ./startup.sh
|
||||||
|
|
||||||
|
> 生产环境使用仅支持Linux或Docker运行
|
||||||
|
|
||||||
|
### docker运行
|
||||||
|
|
||||||
|
1. docker pull xinac721/favicon-api-v3
|
||||||
|
2. docker compose up -d
|
||||||
|
|
||||||
|
> 自行构建:docker build -t favicon-api-v3:latest .
|
||||||
|
|
||||||
|
### API使用
|
||||||
|
|
||||||
https://api.xinac.net/icon/?url=https://www.baidu.com
|
https://api.xinac.net/icon/?url=https://www.baidu.com
|
||||||
|
|
||||||
|
|
||||||
## 运行
|
|
||||||
|
|
||||||
- pip install fastapi uvicorn
|
|
||||||
- uvicorn main:app --reload --port 8081
|
|
||||||
|
|
||||||
|
|
||||||
# 构建镜像(别忘了最后的 .)
|
|
||||||
docker build -t demo-app:latest .
|
|
||||||
|
|
||||||
# 运行容器(-d 后台;-p 宿主机端口:容器端口)
|
|
||||||
docker run -d --name demo -p 8000:8000 demo-app:latest
|
|
||||||
- docker-compose up --build
|
|
|
@ -1,7 +1,7 @@
|
||||||
services:
|
services:
|
||||||
favicon-api:
|
favicon-api-v3:
|
||||||
image: favicon-api:latest
|
image: favicon-api-v3:latest
|
||||||
container_name: favicon-api
|
container_name: favicon-api-v3
|
||||||
ports:
|
ports:
|
||||||
- 8001:8000
|
- 8001:8000
|
||||||
environment:
|
environment:
|
||||||
|
|
|
@ -4,7 +4,7 @@ rewrite ^/icon/(.*)\.png$ /icon/?url=$1;
|
||||||
# 反向代理配置
|
# 反向代理配置
|
||||||
location /icon/
|
location /icon/
|
||||||
{
|
{
|
||||||
proxy_pass http://127.0.0.1:3136;
|
proxy_pass http://127.0.0.1:8001;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
|
|
||||||
## Proxy headers
|
## Proxy headers
|
||||||
|
|
Loading…
Reference in New Issue