Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const path = require('path');
- const express = require('express');
- const fs = require('fs');
- const app = express();
- const cards = require('./public/achat/dat/cards.json');
- var dir = path.join(__dirname, 'public');
- app.use(express.static(dir));
- app.set('views', path.join(__dirname, 'views'));
- app.set('view engine', 'jade');
- var getInv = function(u) {
- var inv = {};
- var filelocation = './public/achat/inv/'+u+'.json';
- if (fs.existsSync(filelocation)) {
- delete require.cache[filelocation];
- inv = require(filelocation);
- } else {
- return "error, file doesn't exist, looking in"+filelocation;
- }
- return inv;
- }
- var getJadeableInv = function(inv) {
- var myCards = {};
- for (card in inv) {
- if (inv[card].num > 0 && cards[card] != undefined) {
- myCards[card] = cards[card];
- console.log(cards[card]);
- myCards[card].img = 'http://www.rtz.cool/achat/img/'+cards[card].img;
- myCards[card].num = inv[card].num;
- }
- }
- return myCards;
- }
- app.get('/j/', function(req,res){
- var inv = getInv(req.query.id);
- var jaded = getJadeableInv(inv);
- res.render('home', {
- cards: jaded
- });
- });
- app.listen(80, function () {
- console.log('Listening on http://localhost:80/');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement