37 lines
827 B
JavaScript
37 lines
827 B
JavaScript
const fs = require('fs');
|
|
const main_dir = 'cwiczenia';
|
|
|
|
const sub_dirs = fs.readdirSync(__dirname + "/static/" + main_dir);
|
|
|
|
const data = {
|
|
folders: sub_dirs,
|
|
lessons: []
|
|
};
|
|
|
|
data.folders.forEach(folder => {
|
|
data.lessons.push(fs.readdirSync(__dirname + "/static/" + main_dir + "/" + folder));
|
|
});
|
|
|
|
console.log(data);
|
|
|
|
const express = require('express');
|
|
const app = express();
|
|
const path = require('path');
|
|
const PORT = 3000;
|
|
|
|
app.get('/', function (req, res) {
|
|
res.sendFile(path.join(__dirname, 'static/pages/index2.html'));
|
|
});
|
|
|
|
app.get('/page_list', function (req, res) {
|
|
res.send(data);
|
|
});
|
|
|
|
app.use(express.static('static/css'));
|
|
app.use(express.static('static/gfx'));
|
|
app.use(express.static('static/' + main_dir));
|
|
|
|
app.listen(PORT, function () {
|
|
console.log(`Start serwera, port: ${PORT}`);
|
|
});
|