oceanpress 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ import { readFileSync, writeFileSync } from "fs";
2
+ import http from "http";
3
+
4
+ const server = http.createServer((req, res) => {
5
+ let body = "";
6
+
7
+ req.on("data", (chunk) => {
8
+ // 将数据块拼接到请求体中
9
+ body += chunk;
10
+ });
11
+
12
+ req.on("end", () => {
13
+ // 请求体接收完毕,可以对其进行处理
14
+ const json = JSON.parse(body);
15
+ console.log(`write ${json.data.length}`, json.path);
16
+ writeFileSync(json.path, json.data);
17
+ // 发送响应
18
+ res.statusCode = 200;
19
+ res.setHeader("Content-Type", "text/plain");
20
+ res.setHeader("Access-Control-Allow-Origin", "*"); // 允许所有来源的请求
21
+ res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE"); // 允许的 HTTP 方法
22
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
23
+ res.end("Received request body" + json.data.length + json.path);
24
+ });
25
+ });
26
+
27
+ const PORT = process.env.PORT || 3000;
28
+
29
+ server.listen(PORT, () => {
30
+ console.log(`[write file] Server is running on port ${PORT}`);
31
+ });
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <link rel="icon" type="image/svg+xml" href="./ocean_press-log" />
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
+ <title>OceanPress</title>
9
+ <meta name="description" content="这是一款从思源笔记本 生成一个静态站点的工具" />
10
+ <meta property="og:description" content="这是一款从思源笔记本 生成一个静态站点的工具" />
11
+ <script type="module" crossorigin src="./assets/index-CgSYWV1W.js"></script>
12
+ </head>
13
+
14
+ <body>
15
+ <div id="app"></div>
16
+ </body>
17
+ <style>
18
+ #app {
19
+ max-width: 800px;
20
+ margin: 0 auto;
21
+ padding: 0 10px;
22
+ }
23
+ </style>
24
+
25
+ </html>
Binary file