MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / get

Method get

apps/chat/views/chat.py:44–66  ·  view source on GitHub ↗
(self, request: Request)

Source from the content-addressed store, hash-verified

42
43class ResourceProxy(APIView):
44 def get(self, request: Request):
45 image_url = request.query_params.get("url")
46 if not image_url:
47 return result.error("Missing 'url' parameter")
48 try:
49
50 # 发送GET请求,流式获取图片内容
51 response = requests.get(
52 image_url,
53 stream=True, # 启用流式响应
54 allow_redirects=True,
55 timeout=10
56 )
57 content_type = response.headers.get('Content-Type', '').split(';')[0]
58 # 创建Django流式响应
59 django_response = StreamingHttpResponse(
60 stream_image(response), # 使用生成器
61 content_type=content_type
62 )
63
64 return django_response
65 except Exception as e:
66 return result.error(f"Image request failed: {str(e)}")
67
68
69class OpenAIView(APIView):

Callers

nothing calls this directly

Calls 3

stream_imageFunction · 0.85
getMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected