mirror of
https://github.com/woodchen-ink/Random-Api.git
synced 2025-07-18 05:52:02 +08:00
修复
This commit is contained in:
parent
150a02b9ba
commit
a0b71538b1
4
eo.js
4
eo.js
@ -1,5 +1,5 @@
|
||||
// 外部 JSON 文件的 URL
|
||||
const CSV_PATHS_URL = 'https://random-api.pages.dev/url.json';
|
||||
const CSV_PATHS_URL = 'https://random-api-file.czl.net/url.json';
|
||||
|
||||
addEventListener('fetch', event => {
|
||||
event.respondWith(handleRequest(event.request));
|
||||
@ -43,7 +43,7 @@ async function handleRequest(request) {
|
||||
}
|
||||
} else {
|
||||
// 如果不是 CSV 资源路径,返回 index.html 内容
|
||||
const indexHtmlResponse = await fetch('https://random-api.pages.dev');
|
||||
const indexHtmlResponse = await fetch('https://random-api-file.czl.net');
|
||||
return new Response(indexHtmlResponse.body, {
|
||||
headers: { 'Content-Type': 'text/html' },
|
||||
});
|
||||
|
12
index.html
12
index.html
@ -2,7 +2,7 @@
|
||||
<html lang="zh-cmn-Hans" class="mdui-theme-dark">
|
||||
|
||||
<head>
|
||||
<title>随机文件api-wood</title>
|
||||
<title>随机文件api</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="shortcut icon" size="32x32" href="https://cdn-r2.czl.net/2023/06/20/649168ebc2b5d.png">
|
||||
@ -88,9 +88,9 @@
|
||||
object-fit: cover;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="https://cdnjs.czl.net/ajax/libs/mdui/2.1.1/mdui.min.css">
|
||||
<script src="https://cdnjs.czl.net/ajax/libs/mdui/2.1.1/mdui.global.js"></script>
|
||||
<script src="https://cdnjs.czl.net/ajax/libs/markdown-it/13.0.2/markdown-it.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdui/2.1.1/mdui.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mdui/2.1.1/mdui.global.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/13.0.2/markdown-it.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body class="mdui-prose">
|
||||
@ -110,7 +110,7 @@
|
||||
});
|
||||
|
||||
// 异步加载 index.md 文件内容
|
||||
fetch('https://random-api.pages.dev/index.md')
|
||||
fetch('https://random-api-file.czl.net/index.md')
|
||||
.then(response => response.text())
|
||||
.then(markdownText => {
|
||||
// 渲染 Markdown 内容
|
||||
@ -120,4 +120,4 @@
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
@ -4,7 +4,7 @@ const app = express();
|
||||
const port = 5003;
|
||||
|
||||
// 外部 JSON 文件的 URL
|
||||
const CSV_PATHS_URL = 'https://random-api.pages.dev/url.json';
|
||||
const CSV_PATHS_URL = 'https://random-api-file.czl.net/url.json';
|
||||
|
||||
/**
|
||||
* 处理客户端请求,并根据请求的URL路径获取对应的CSV文件中的随机一行的URL,然后重定向到该URL。
|
||||
@ -51,7 +51,7 @@ async function handleRequest(req, res) {
|
||||
}
|
||||
} else {
|
||||
// 请求路径不在配置中,返回默认首页
|
||||
const indexHtmlResponse = await fetch('https://random-api.pages.dev');
|
||||
const indexHtmlResponse = await fetch('https://random-api-file.czl.net');
|
||||
const indexHtml = await indexHtmlResponse.text();
|
||||
return res.type('html').send(indexHtml);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user