ProjectIDXExpressExample/index.js

22 lines
513 B
JavaScript
Raw Normal View History

2024-05-18 15:24:28 +00:00
const express = require('express');
const path = require('path')
const app = express();
const port = parseInt(process.env.PORT) || process.argv[3] || 8080;
app.use(express.static(path.join(__dirname, 'public')))
.set('views', path.join(__dirname, 'views'))
.set('view engine', 'ejs');
app.get('/', (req, res) => {
res.render('index');
});
app.get('/api', (req, res) => {
res.json({"msg": "Hello FreshBrewed."});
});
app.listen(port, () => {
console.log(`Listening on http://localhost:${port}`);
})