Update index.js
Browse files
index.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
| 1 |
import crc32 from './crc32.js'
|
| 2 |
import http from 'axios'
|
| 3 |
-
import
|
| 4 |
|
| 5 |
-
const app =
|
|
|
|
| 6 |
|
| 7 |
-
app.use(
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
const file = await http({
|
| 10 |
method: 'GET',
|
| 11 |
url: file_url,
|
|
@@ -28,6 +32,6 @@ app.use(async ctx => {
|
|
| 28 |
ctx.body = upload_result.data
|
| 29 |
})
|
| 30 |
|
| 31 |
-
app.listen(
|
| 32 |
-
console.log(
|
| 33 |
})
|
|
|
|
| 1 |
import crc32 from './crc32.js'
|
| 2 |
import http from 'axios'
|
| 3 |
+
import express from 'express'
|
| 4 |
|
| 5 |
+
const app = express()
|
| 6 |
+
const port = 7860
|
| 7 |
|
| 8 |
+
app.use(express.json())
|
| 9 |
+
app.use(express.urlencoded({ extended: true }))
|
| 10 |
+
|
| 11 |
+
app.get('*', async (req, res) => {
|
| 12 |
+
const file_url = req.path.replace(/^\//, '')
|
| 13 |
const file = await http({
|
| 14 |
method: 'GET',
|
| 15 |
url: file_url,
|
|
|
|
| 32 |
ctx.body = upload_result.data
|
| 33 |
})
|
| 34 |
|
| 35 |
+
app.listen(port, async () => {
|
| 36 |
+
console.log(`http://localhost:${port}`)
|
| 37 |
})
|