我的另一盘类似的教程:https://www.dong-blog.fun/post/1942
以下是一个简单的FastAPI应用程序示例,包含你提到的测试端口代码:
首先,确保你已经安装了 FastAPI 和 Uvicorn。如果还没有安装,可以使用 pip 进行安装:
bashpip install fastapi uvicorn requests
我们可以按照你的要求配置 Nginx 将客户端的请求头信息及其他设置信息保持和转发。以下是详细的步骤:
创建 Nginx 配置文件:
首先需要创建一个 Nginx 配置文件,比如 nginx.conf
:
nginxevents {} http { upstream backend { server 101.136.8.66:7890; } server { listen 7860; location / { proxy_pass http://backend; # 保持客户端的请求头信息 proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # HTTP 版本和连接管理 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; # 超时设置 proxy_connect_timeout 300s; proxy_read_timeout 300s; } } }
模型:https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B
下载模型,这样下载太慢,换个源头:
bash# Make sure you have git-lfs installed (https://git-lfs.com)
git lfs install
git clone https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B
# If you want to clone without large files - just their pointers
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B
pythonfrom collections import deque
def bfs(起始点):
# 初始化队列和访问标记
queue = deque()
queue.append(起始点)
visited = set()
visited.add(起始点)
while queue:
# 弹出当前节点
node = queue.popleft()
# 处理当前节点(例如记录路径、判断条件等)
处理当前节点
# 遍历相邻节点
for neighbor in 获取相邻节点(node):
if neighbor 未越界 and neighbor 未访问:
queue.append(neighbor)
visited.add(neighbor) # 必须在此处标记已访问