<commit_before>const fs = require('fs')
const path = require('path')
const server = require('express')()
const { createBundleRenderer } = require('vue-server-renderer')

// server.get('*', (req, res) => {
  // const filePath = path.join(__dirname,'./dist/bundle.server.js')
  // const file = fs.readFileSync(filePath, 'utf8')
  // const renderer = createBundleRenderer(file)
  // const context = { url: req.url }
  // renderer.renderToString(context, (err, html) => {
  //   if (err) {
  //     console.log(err)
  //     res.status(500).end('Internal Server Error')
  //     return
  //   }
  //   console.log(html)
  //   res.end(html)
  // })
// })

server.get('/:id', (req, res) => {
    const filePath = path.join(__dirname,'./dist/bundle.server.js')
    const file = fs.readFileSync(filePath, 'utf8')
    const renderer = createBundleRenderer(file)
    console.log(req.params.id)
    const context = { url: req.params.id }
    renderer.renderToString(context, (err, html) => {
        if (err) {
            console.log(err)
            res.status(500).end('Internal Server Error')
            return
        }
        console.log(html)
        res.end(html)
    })
})

server.get('/', (req, res) => {
    const filePath = path.join(__dirname,'./dist/bundle.server.js')
    const file = fs.readFileSync(filePath, 'utf8')
    const renderer = createBundleRenderer(file)
    const context = { url: req.url }
    renderer.renderToString(context, (err, html) => {
        if (err) {
            console.log(err)
            res.status(500).end('Internal Server Error')
            return
        }
        console.log(html)
        res.end(html)
    })
})



server.listen(8090, function(){
  console.log('server started on port 8090')
})<commit_msg>合并server方法<commit_after>const fs = require('fs')
const path = require('path')
const server = require('express')()
const {createBundleRenderer} = require('vue-server-renderer')

// server.get('*', (req, res) => {
// const filePath = path.join(__dirname,'./dist/bundle.server.js')
// const file = fs.readFileSync(filePath, 'utf8')
// const renderer = createBundleRenderer(file)
// const context = { url: req.url }
// renderer.renderToString(context, (err, html) => {
//   if (err) {
//     console.log(err)
//     res.status(500).end('Internal Server Error')
//     return
//   }
//   console.log(html)
//   res.end(html)
// })
// })

server.get('/:id', (req, res) => {
    const context = {
        url: req.params.id
    }
    htmlRender(context, res)
})

server.get('/', (req, res) => {
    const context = {
        url: req.url
    }
    htmlRender(context, res)
})

function htmlRender(context, res) {
    const filePath = path.join(__dirname, './dist/bundle.server.js')
    const file = fs.readFileSync(filePath, 'utf8')
    const renderer = createBundleRenderer(file)
    renderer.renderToString(context, (err, html) => {
        if (err) {
            console.log(err)
            res.status(500).end('Internal Server Error')
            return
        }
        // console.log(html)
        res.writeHead(200, {
            'Content-Type': 'text/html;charset=utf-8'
        });
        res.end(html)
    })
}

server.listen(8090, function() {
    console.log('server started on port 8090')
})
{'fraction_non_alphanumeric': 0.1744078745001538, 'fraction_numerical': 0.012303906490310674, 'mean_word_length': 2.5657894736842106, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6169461', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1056, 'n_words': 202}