|
|
const express = require('express'); |
|
|
const basicAuth = require('basic-auth'); |
|
|
const httpProxy = require('http-proxy'); |
|
|
const app = express(); |
|
|
const port = 8080; |
|
|
const proxy = httpProxy.createProxyServer(); |
|
|
|
|
|
|
|
|
const authMiddleware = (req, res, next) => { |
|
|
const unauthorized = (res) => { |
|
|
res.set('WWW-Authenticate', 'Basic realm=Authorization Required'); |
|
|
return res.sendStatus(401); |
|
|
}; |
|
|
const user = basicAuth(req); |
|
|
if (!user || !user.name || !user.pass) { |
|
|
return unauthorized(res); |
|
|
} |
|
|
if (user.name === 'ace' && user.pass === '2024=ace=2024') { |
|
|
return next(); |
|
|
} else { |
|
|
return unauthorized(res); |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
app.use(authMiddleware); |
|
|
|
|
|
|
|
|
app.use('/api', (req, res) => { |
|
|
proxy.web(req, res, { target: 'http://127.0.0.1:8999' }); |
|
|
}); |
|
|
app.use('/lib', (req, res) => { |
|
|
proxy.web(req, res, { target: 'http://127.0.0.1:8999' }); |
|
|
}); |
|
|
app.use('/scripts', (req, res) => { |
|
|
proxy.web(req, res, { target: 'http://127.0.0.1:8999' }); |
|
|
}); |
|
|
app.use('/style.css', (req, res) => { |
|
|
proxy.web(req, res, { target: 'http://127.0.0.1:8999/style.css' }); |
|
|
}); |
|
|
app.use('/user.css', (req, res) => { |
|
|
proxy.web(req, res, { target: 'http://127.0.0.1:8999/user.css' }); |
|
|
}); |
|
|
|
|
|
|
|
|
app.get('/', (req, res) => { |
|
|
|
|
|
const pageHeader = ` |
|
|
<html> |
|
|
<head> |
|
|
<!-- Bootstrap CSS --> |
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> |
|
|
<!-- Include jQuery --> |
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> |
|
|
<!-- Include jsTree --> |
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" /> |
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script> |
|
|
<style> |
|
|
body { |
|
|
background-color: #f1f1f1; |
|
|
margin: 0; |
|
|
font-family: Arial, sans-serif; |
|
|
} |
|
|
|
|
|
.header, .footer { |
|
|
position: fixed; |
|
|
left: 0; |
|
|
width: 100%; |
|
|
text-align: center; |
|
|
background-color: #f1f1f1; |
|
|
z-index: 1000; /* Ensure it's above other elements */ |
|
|
|
|
|
} |
|
|
|
|
|
.header { |
|
|
top: 0; |
|
|
background-color: #f1f1f1; |
|
|
padding-top:15px; |
|
|
} |
|
|
|
|
|
.footer { |
|
|
bottom: -5; |
|
|
background-color: #f1f1f1; |
|
|
z-index: 1002; /* Stay on top */ |
|
|
} |
|
|
|
|
|
iframe { |
|
|
width: 100%; |
|
|
height:90vh; /* Adjusted height to account for header and footer */ |
|
|
border: none; |
|
|
margin-top: 70px; |
|
|
} |
|
|
|
|
|
.file-manager { |
|
|
height: 75vh; /* Full height */ |
|
|
width: 75px; /* Set the width of the sidebar */ |
|
|
position: fixed; /* Fixed Sidebar (stay in place on scroll) */ |
|
|
z-index: 1001; /* Stay on top */ |
|
|
top: 95; /* Stay at the top */ |
|
|
left:0; |
|
|
border: 1px; |
|
|
border-color: cyan; |
|
|
background-color: #252525; |
|
|
overflow-x: hidden; /* Disable horizontal scroll */ |
|
|
padding-top: 30px; |
|
|
} |
|
|
|
|
|
/* Style the links inside the navigation bar */ |
|
|
.file-manager a { |
|
|
padding: 6px 8px 6px 16px; |
|
|
text-decoration: none; |
|
|
font-size: 25px; |
|
|
color: #818181; |
|
|
display: block; |
|
|
} |
|
|
|
|
|
/* When you mouse over the navigation links, change their color */ |
|
|
.file-manager a:hover { |
|
|
color: #f1f1f1; |
|
|
} |
|
|
|
|
|
</style> |
|
|
|
|
|
</head> |
|
|
<body> |
|
|
<div class="file-manager"></div> |
|
|
<div class="header"> |
|
|
<a href="/"> |
|
|
<svg style="height: 35px; position: absolute; left: 15px; top: 15px;" preserveAspectRatio="xMidYMid meet" data-bbox="3.7 3 731.3 210.6" viewBox="3.7 3 731.3 210.6" xmlns="http://www.w3.org/2000/svg" data-type="color" role="presentation" aria-hidden="true" aria-label=""> |
|
|
<g> |
|
|
<path d="M240.1 97.5 275.5 3H294l35.2 94.5h-16.6l-8.9-23.3H265l-8.8 23.3h-16.1zM269.3 61h30.1l-15.1-41.2-15 41.2z" fill="#000000" data-color="1"></path> |
|
|
<path d="M329.1 63.1c0-21.3 13.8-35.5 34.7-35.5 17.8 0 28.9 9.9 31.7 25.5h-15.2c-2-8.1-7.8-13.1-16.8-13.1-11.7 0-19.4 9.4-19.4 23.1 0 13.5 7.7 22.8 19.4 22.8 8.9 0 14.8-5.1 16.6-13.1h15.4c-2.7 15.7-14.4 25.5-32.1 25.5-21 0-34.3-13.6-34.3-35.2z" fill="#000000" data-color="1"></path> |
|
|
<path d="M401.4 63.1c0-21.3 13.6-35.5 34-35.5 20 0 33.3 12.7 33.7 32.9 0 1.8-.1 3.6-.4 5.5h-52.1v1c.4 11.7 7.8 19.4 19.3 19.4 8.9 0 15.4-4.5 17.4-12.1h14.6c-2.4 13.6-14 24-31.2 24-21.7 0-35.3-14-35.3-35.2zm52.6-7.7c-1.2-10.3-8.4-16.1-18.5-16.1-9.3 0-17.3 6.2-18.4 16.1H454z" fill="#000000" data-color="1"></path> |
|
|
<path d="m241.4 212.7 36.6-94.5h8.5l36.4 94.5H315l-11.3-28.9h-43.5l-11.3 28.9h-7.5zm21-35.6h39.1L282 126.4l-19.6 50.7z" fill="#000000" data-color="1"></path> |
|
|
<path d="M332.2 118.3h7.3v94.5h-7.3v-94.5z" fill="#000000" data-color="1"></path> |
|
|
<path d="M394 183.7c.9 14 11.7 23.2 27.7 23.2 15.2 0 25.5-7.3 25.5-19.4 0-13.8-13.2-16.7-28.1-19.3-15.1-2.6-30.5-6.6-30.5-24.6 0-16.1 12.6-26.2 31.7-26.2 19.3 0 31.6 10.7 32.9 26.9h-7.4c-1.6-12.3-11.3-20.2-25.5-20.2-14.8 0-24.4 6.9-24.4 19.2 0 13.5 12.6 15.9 27 18.4 15.7 2.7 31.6 7.3 31.6 25.2 0 15.9-13.1 26.7-32.9 26.7-21.2 0-34.1-12-35.1-29.8h7.5z" fill="#000000" data-color="1"></path> |
|
|
<path d="M471.3 150.7h-13v-6.3h13v-19.2h6.9v19.2h18.5v6.3h-18.5v46c0 7 2.6 9.7 9.7 9.7h9.4v6.3h-10c-11.6 0-16.1-5-16.1-15.9v-46.1z" fill="#000000" data-color="1"></path> |
|
|
<path d="M554.8 144.3h6.9v68.4h-6.1l-.9-14.4c-3.9 8.8-11.9 15.2-24 15.2-15.1 0-26.3-9.4-26.3-30.9v-38.3h6.9v37.9c0 16.3 7.8 25 20.5 25 14.2 0 23.1-11.3 23.1-29.3v-33.6z" fill="#000000" data-color="1"></path> |
|
|
<path d="M631.1 118.3h6.9v94.5h-6l-1.1-15.7c-4.3 9.6-13.2 16.5-26 16.5-18.8 0-32.3-13.5-32.3-35.1 0-20.6 13.5-35 32.3-35 12.8 0 22 6.5 26.2 16.2v-41.4zm.1 60.3c0-17-10.5-29-25.8-29-15.2 0-25.8 12-25.8 28.9 0 17 10.5 28.9 25.8 28.9 15.3-.1 25.8-11.9 25.8-28.8z" fill="#000000" data-color="1"></path> |
|
|
<path d="M650.1 125c0-2.8 2.2-4.9 4.9-4.9s4.9 2 4.9 4.9-2.2 4.9-4.9 4.9-4.9-2.1-4.9-4.9zm1.4 19.3h6.9v68.4h-6.9v-68.4z" fill="#000000" data-color="1"></path> |
|
|
<path d="M669.3 178.4c0-20.6 13.5-35 32.8-35 19.3 0 32.9 14.3 32.9 35 0 20.8-13.6 35.1-32.9 35.1-19.3 0-32.8-14.3-32.8-35.1zm58.5 0c0-16.9-10.5-28.9-25.8-28.9-15.2 0-25.8 12-25.8 28.9 0 17 10.5 28.9 25.8 28.9s25.8-11.8 25.8-28.9z" fill="#000000" data-color="1"></path> |
|
|
<path d="M169.9 189.6v21.2h41.5v-41.5h-21.2c-11.2 0-20.3 9.1-20.3 20.3z" fill="#000000" data-color="1"></path> |
|
|
<path d="M116.2 97c-2.1 4-5 9.2-8.9 16.6-5.7 10.8-17 14.2-28.9 14.2H7.1c-1.9 0-3.4 1.5-3.4 3.4v38.1h45.7c17.6 0 29.5-4.5 37.1-19.6 8.2-16.2 21.1-21.9 39-21.9h85.8V86.2h-77.2c-7.4 0-14.3 4.1-17.9 10.8z" fill="#000000" data-color="1"></path> |
|
|
<path d="M165.2 13.9c-2.1 4-5 9.2-8.9 16.6-5.7 10.8-17 14.2-28.9 14.2H53.2c-1.9 0-3.4 1.5-3.4 3.4v38.1h48.6c17.6 0 29.5-4.5 37.1-19.6 8.2-16.2 21.1-21.9 39-21.9h36.8V3.1h-28.2c-7.4 0-14.3 4.1-17.9 10.8z" fill="#000000" data-color="1"></path> |
|
|
<path d="M165.2 13.9c-2.1 4-5 9.2-8.9 16.6-5.7 10.8-17 14.2-28.9 14.2H53.2c-1.9 0-3.4 1.5-3.4 3.4v38.1h48.6c17.6 0 29.5-4.5 37.1-19.6 8.2-16.2 21.1-21.9 39-21.9h36.8V3.1h-28.2c-7.4 0-14.3 4.1-17.9 10.8z" fill="#000000" data-color="1"></path> |
|
|
<path d="M116.2 97c-2.1 4-5 9.2-8.9 16.6-5.7 10.8-17 14.2-28.9 14.2H7.1c-1.9 0-3.4 1.5-3.4 3.4v38.1h45.7c17.6 0 29.5-4.5 37.1-19.6 8.2-16.2 21.1-21.9 39-21.9h85.8V86.2h-77.2c-7.4 0-14.3 4.1-17.9 10.8z" fill="#000000" data-color="1"></path> |
|
|
<path d="M169.9 189.6v21.2h41.5v-41.5h-21.2c-11.2 0-20.3 9.1-20.3 20.3z" fill="#000000" data-color="1"></path> |
|
|
</g> |
|
|
</svg> |
|
|
</a> |
|
|
<b>ACE AI TestBed</b> |
|
|
</div> |
|
|
|
|
|
<iframe class="iframe" src="http://aceadoor.smartpickai.com:41289/api"></iframe> |
|
|
`; |
|
|
|
|
|
const footDiv = ` |
|
|
<div class="footer"> |
|
|
<p>© 2024 ACE AI Studio</p> |
|
|
</div> |
|
|
</body> |
|
|
</html>`; |
|
|
|
|
|
res.send(pageHeader + footDiv); |
|
|
}); |
|
|
|
|
|
|
|
|
app.listen(port, () => { |
|
|
console.log(`Server running at http://127.0.0.1:${port}`); |
|
|
}); |