app.js 585 B

123456789101112131415161718192021222324
  1. const express = require('express');
  2. const path = require('path');
  3. const app = express();
  4. const { getLocale } = require('./libs/utils');
  5. // 设置视图引擎为EJS
  6. app.set('view engine', 'ejs');
  7. // 设置视图目录
  8. app.set('views', path.join(__dirname, 'views'));
  9. app.use(express.static(path.join(__dirname, 'dist')));
  10. app.use('/', require('./routes/index'));
  11. app.use('/proxy', require('./routes/proxy'));
  12. // 启动服务器,监听3000端口
  13. const PORT = process.env.PORT || 3000;
  14. app.listen(PORT, () => {
  15. console.log(`Server is running on http://localhost:${PORT}`);
  16. });