Ignore:
Timestamp:
2022-07-29T22:20:27+12:00 (21 months ago)
Author:
davidb
Message:

Server side changes to match theCallback method added in that determines where there are DOI records for both CrossRef and Core

File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/bib-stinky/trunk/nodejs-server/express-web-server.js

    r36333 r36350  
    11// Setup Express
    2 const path      = require('path');
    3 const { spawn } = require('child_process');
     2const path    = require('path');
    43
    54const express = require("express");
    65const cors    = require("cors");
    7 
    86
    97const app = express();
     
    1210const public_dir = path.join(__dirname, 'public')
    1311
    14 
    1512app.use(cors());
    1613app.use('/', express.static(public_dir))
    1714
    18 //// To help with POST and PUT requests to the server
    19 //app.use(express.json());
    20 //app.use(express.urlencoded({ extended: true }));
     15// // To help with POST and PUT requests to the server
     16// app.use(express.json());
     17// app.use(express.urlencoded({ extended: true }));
    2118
    2219
     
    2522});
    2623
    27 
    28 app.get("/api/get-doi", (req, res) => {
    29     var doi = req.query.doi;
    30 
    31     var dataToSend;
    32 
    33     // Spawn new child process to call the python script
    34     const python = spawn('python3', ['doi-stinky/oacore-get-doi.py', doi, "oacore-output.json"]);
    35    
    36     // Collect data from script
    37     python.stdout.on('data', function (data) {
    38     console.log('Pipe data from python script ...');
    39     dataToSend = data.toString();
    40     });
    41    
    42     // In close event we are sure that stream from child process is closed
    43     python.on('close', (code) => {
    44     console.log(`child process close all stdio with code ${code}`);
    45    
    46     //res.send(dataToSend)
    47     res.sendFile("oacore-output.json", { root: __dirname });   
    48     });   
    49 });
     24require("./api.routes.js")(app);
    5025
    5126
Note: See TracChangeset for help on using the changeset viewer.