-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
25 lines (25 loc) · 994 Bytes
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
$api_response = [];
$p = $_POST["inputs"];
$nums = $_POST["num"];
if ($p != "") {
$api_query = "{\"fn_index\":0,\"data\":[\"$p\",$nums,\"中文CLIP(Base)\",\"是\"]}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://modelscope.cn/api/v1/studio/damo/chinese_clip_applications/gradio/api/predict/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $api_query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
$rp = curl_exec($ch);
$api_response = json_decode($rp, true)["data"][0];
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpcode == 500) echo "您输入的内容不符合网站要求,请您更换后试试~";
elseif ($httpcode != 200) echo "error";
curl_close($ch);
}
?>
<br>
<script>
var api_response = <?= json_encode($api_response) ?>;
for (var i = 0; i < api_response.length; i++) document.write("<img src='" + api_response[i] + "' alt='" + api_response[i] + "'>");
</script>