Post request triggered two times

I have 70 million points in Lidar ‘.las’ binary file.

with node.js and express.js I created app and select file of 800MB with input box.
on submit button I select post method to send that file to server with action ‘/upload’.

using @loaders.core & @loaders.las, I got points details and save it to json file. but due to high number of points I cant save it to one file. that is why I save 5 million points in one file and than create new file. time taken to create these files is around 5 min but after creating all 14 files, once again post request trigger and start the same process.

import cors from 'cors';
import express from 'express';
import timeout from 'connect-timeout';
import path from 'path';
import upload from 'express-fileupload';
import fs from 'fs';

var app = express()
var port = 80
app.use(cors())

import pkg from '@loaders.gl/core';
import LASpkg from '@loaders.gl/las';
const { load } = pkg
const { LASLoader } = LASpkg

var __dirname = path.resolve();
var filename = 0

app.use(express.static('public'))

app.use(upload())

app.get('/', (req, res) => {

    res.sendFile(__dirname + '/public/index.html')

})

app.post('/upload', (req, res) => {
    if (req.files) {
        var file = req.files.file
        const data = load(file.data, LASLoader);
        data.then((e) => {
            var points = Object.values(e.attributes.POSITION.value)

            while (points.length && filename < 15) {

                if (filename < 15) {
                    var b = points.splice(0, 5000000);
                    fs.writeFileSync('./public/assests/user' + filename + '.json', JSON.stringify(b));
                    filename++
                }
            }
            res.sendFile(__dirname + '/public/pointerLoad.html')

        })
    }
})

app.use('/filecount', async (req, res, next) => {
    var files = ''

    var filenames = await fs.readdirSync('./public/assests');

    res.json({ data: filenames })

    await fs.readdirSync('./public/assests').forEach(file => {

        console.log(file);

        files += file.replace('json', '') + ','

    });

    next()

})

var server = app.listen(port, () => {

    console.log("Server is running on port: " + port)

})