Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var express = require('express');
- var app = express();
- var fs = require('fs');
- var bodyParser = require('body-parser');
- app.use(bodyParser.json());
- app.use(bodyParser.urlencoded({ extended: true }));
- //var session = require('express-session');
- //app.use(session({secret: 'SecurityKeyIDontKnowWhatIsHappening',resave: true,saveUninitialized : false}));
- app.use(express.static(__dirname + '/homepage'));
- var obj = new Array();
- app.post('/add_user', function(req, res) {
- //console.log("here");
- var username = req.body.firstname;
- var mail = req.body.email;
- var password = req.body.password;
- //var file_content = fs.readFileSync(__dirname +'/videodata.json');
- //var content = JSON.parse(file_content);
- /* obj.push( {
- ID : username,
- m : mail,
- p : password
- }); */
- // console.log(obj[0].ID + "lala ");
- // obj.push();
- // content = obj;
- //fs.writeFileSync(__dirname +'videodata.json', JSON.stringify(content, null, 4));
- // console.log(content.users[0].ID + "lala ");
- console.log(username + mail + password);
- // res.redirect('/form');
- });
- app.post('/log', function(req, res) {
- // console.log("here");
- var username2 = req.body.formusername;
- var password2 = req.body.formpassword;
- console.log(username2 + password2);
- // res.redirect('/form');
- });
- app.get('/', function(req, res){
- res.sendfile(__dirname + '/homepage/HomePage.html');
- console.log("server is running now");
- // var file_content = fs.readFileSync('videodata.json');
- /* var content = JSON.parse(file_content);
- //console.log("Password:" , content.categoryName);
- var result ="";
- for(var i=0; i<response.categories.length; i++)
- {
- result += response.data[i].categoryName + ', ';
- }
- console.log(result);
- */
- });
- var server = app.listen(8888);
- console.log("hiiiiiiiiiiiii");
- /*-----------------------------------------------*/
- /*console.log("\n *EXIT* \n");
- res.write(jsonContent.categories[0].categoryID);
- jsonContent.categories.push( {
- "categoryID": "salmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
- "parentID": "000",
- "subjectID": "0",
- "categoryName": "c at e g o ry na m e",
- "categoryDescription": "just trying dont do that again salma ",
- "videosCount": "9876",
- "forumCategoryID": "12345"
- });
- res.write(jsonContent.categories[jsonContent.categories.length-1].categoryID+"\n");
- jsonContent.categories[jsonContent.categories.length-1].categoryID = "nooooooooooo";
- res.write(jsonContent.categories[jsonContent.categories.length-1].categoryID);
- res.end();
- }
- http.createServer(onRequest).listen(8888);
- console.log("hello world salmaaaaaaaaaaa");*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement