Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Henry Schliebe: all three challenges #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions HenrySchliebeChallenges/Back End/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var express = require('express');
var bodyParser = require('body-parser');
var app = express();

app.use(express.urlencoded({extended: true}));
app.use(express.json());

var list = [5,4,3,2,1];
//default list in case you wanted to try the get route before posting anything

app.post('/data', function(req,res){
console.log('server - get /data');
console.log('server - recieved numbers: '+req.body.numbers);
var reqnums = req.body.numbers;
if(reqnums.length!==500) res.status(400).send('error: must send exactly 500 numbers');
else{
if(isNaN(reqnums[0])) res.status(400).send('error: must only send numbers');
list = reqnums;
res.send('we got it');
}
});

app.get('/data', function(req,res){
var sendlist = list.sort((a,b)=>{return a-b});
res.send({numbers:sendlist});
});

app.listen('3000','127.0.0.1', function(){
console.log('server started');
});
Loading