Update index.js
Browse files
index.js
CHANGED
@@ -1,10 +1,12 @@
|
|
|
|
1 |
const fetch = require('node-fetch');
|
2 |
const FormData = require('form-data');
|
3 |
const sharp = require('sharp');
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
8 |
|
9 |
if (!imageUrl) {
|
10 |
return res.status(400).send('');
|
@@ -50,6 +52,9 @@ async function onRequest(req, res) {
|
|
50 |
console.error('压缩图像时出错:', error);
|
51 |
res.status(500).send('');
|
52 |
}
|
53 |
-
}
|
54 |
|
55 |
-
|
|
|
|
|
|
|
|
1 |
+
const express = require('express');
|
2 |
const fetch = require('node-fetch');
|
3 |
const FormData = require('form-data');
|
4 |
const sharp = require('sharp');
|
5 |
|
6 |
+
const app = express();
|
7 |
+
|
8 |
+
app.get('/resize', async (req, res) => {
|
9 |
+
const imageUrl = req.query.q;
|
10 |
|
11 |
if (!imageUrl) {
|
12 |
return res.status(400).send('');
|
|
|
52 |
console.error('压缩图像时出错:', error);
|
53 |
res.status(500).send('');
|
54 |
}
|
55 |
+
});
|
56 |
|
57 |
+
const PORT = process.env.PORT || 3000;
|
58 |
+
app.listen(PORT, () => {
|
59 |
+
console.log(`Server is running on port ${PORT}`);
|
60 |
+
});
|