forked from rugpullindex/design-system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (30 loc) · 1.15 KB
/
index.js
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const express = require('express')
const axios = require('axios')
const fs = require('fs')
const path = require('path')
const PORT = 5000
const url = "https://rugpullindex.com"
const app = express()
axios(url)
.then(response => {
const html = response.data //index.html
const new_html = html.replace("/93218339c23.css", `/local.css`)
//the above line will change the href file location in the html file
//to the local css file in the design system repo
//Make the cache directory if cache directory doesnt exist
if(!fs.existsSync(path.join(__dirname, 'cache'))){
fs.mkdir(path.join(__dirname, 'cache'), function(err) {
if(err) { return console.log(err) }
})
}
//Save the new html file to cache folder in design system repo
fs.writeFile('cache/index.html', new_html, function(err) {
if(err) { return console.log(err) }
})
})
app.use(express.static(__dirname))
app.get('/', function(req, res) {
//Serve the written index.html file on localhost:5000/
res.sendFile(path.join(__dirname, 'cache/index.html'))
})
app.listen(PORT, () => console.log('rugpullindex runs on localhost:5000/'))