From 8c3ffcc5fada71f9bf9a957d99a0a47a0c07ea37 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Sun, 21 Nov 2021 14:37:35 -0700 Subject: [PATCH] Start script to fetch data from server --- app.js | 4 +++- public/scripts/submit.js | 0 routes/data.js | 10 ++++++++++ views/layout.pug | 1 + views/submit.pug | 3 +++ 5 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 public/scripts/submit.js create mode 100644 routes/data.js diff --git a/app.js b/app.js index 3cff1ca..29f7b4f 100644 --- a/app.js +++ b/app.js @@ -6,7 +6,8 @@ var logger = require('morgan'); var indexRouter = require('./routes/index'); var usersRouter = require('./routes/users'); -var submitRouter = require('./routes/submit') +var submitRouter = require('./routes/submit'); +var dataRouter = require('./routes/data'); var app = express(); @@ -23,6 +24,7 @@ app.use(express.static(path.join(__dirname, 'public'))); app.use('/', indexRouter); app.use('/users', usersRouter); app.use('/submit', submitRouter); +app.use('/data', dataRouter); // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/public/scripts/submit.js b/public/scripts/submit.js new file mode 100644 index 0000000..e69de29 diff --git a/routes/data.js b/routes/data.js new file mode 100644 index 0000000..05f5291 --- /dev/null +++ b/routes/data.js @@ -0,0 +1,10 @@ +var express = require('express'); +var router = express.Router(); +var database = require('../database/database'); + +/* GET submit page. */ +router.get('/', function(req, res, next) { + res.json( { message : "test" }); +}); + +module.exports = router; \ No newline at end of file diff --git a/views/layout.pug b/views/layout.pug index 69f5a59..e4f85eb 100644 --- a/views/layout.pug +++ b/views/layout.pug @@ -7,3 +7,4 @@ html block stylesheets body block content + block scripts diff --git a/views/submit.pug b/views/submit.pug index 385ad51..149fde7 100644 --- a/views/submit.pug +++ b/views/submit.pug @@ -39,3 +39,6 @@ block content input(class="score-input", type="number", name="team2-score", value="0") span(class='form-section') button(type="submit") Submit + +block scripts + script(src='/scripts/submit.js') \ No newline at end of file