tijiao
This commit is contained in:
68
算法.txt
Normal file
68
算法.txt
Normal file
@@ -0,0 +1,68 @@
|
||||
# from langflow.field_typing import Data
|
||||
import base64
|
||||
import requests
|
||||
from langflow.custom import Component
|
||||
from langflow.io import MessageTextInput, Output
|
||||
from langflow.schema import Data, Message
|
||||
|
||||
|
||||
class CustomComponent(Component):
|
||||
display_name = "结果查看并上传服务器"
|
||||
description = "结果查看并上传服务器."
|
||||
documentation: str = "https://docs.langflow.org/components-custom-components"
|
||||
icon = "code"
|
||||
name = "CustomComponent"
|
||||
|
||||
inputs = [
|
||||
MessageTextInput(
|
||||
name="image_dir",
|
||||
display_name="文件路径",
|
||||
info="文件路径",
|
||||
value="",
|
||||
tool_mode=True,
|
||||
),
|
||||
MessageTextInput(
|
||||
name="image_filename",
|
||||
display_name="文件名称",
|
||||
info="文件名称",
|
||||
value="",
|
||||
tool_mode=True,
|
||||
),
|
||||
]
|
||||
|
||||
outputs = [
|
||||
Output(display_name="输出值", name="output", method="get_result"),
|
||||
]
|
||||
|
||||
def get_result(self) -> Message:
|
||||
# 发送请求
|
||||
# response = requests.get('http://172.16.102.3:30256/image')
|
||||
# image_url = 'https://minio.maimaiag.com/mx-bucket/result.png'
|
||||
# 结果上传minio
|
||||
url = 'http://172.16.102.3:30256/image'
|
||||
data = {
|
||||
"image_dir": self.image_dir,
|
||||
"image_filename": self.image_filename
|
||||
}
|
||||
image_url = requests.post(url,data=data)
|
||||
|
||||
# 创建HTML内容
|
||||
#
|
||||
html_content = f"""
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>MinIO Image Display</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Displaying Image from MinIO</h1>
|
||||
<img src="{image_url}" alt="Image from MinIO">
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
return Message(
|
||||
text=html_content
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user