Skip to content

Instantly share code, notes, and snippets.

View dileephell's full-sized avatar
🎯
Focusing

Dileep Singh dileephell

🎯
Focusing
View GitHub Profile
var http = require('http'),
sys = require('sys'),
fs = require('fs'),
ws = require('./ws.js');
var clients = [];
http.createServer(function(request, response)
{
var sys = require('sys'),
http = require('http');
http.createServer(function (req, res) {
switch (req.url) {
case '/':
res.writeHead(200, {'Content-type': 'text/html'});
res.end(
'<form action="/myaction" method="post" enctype="multipart/form-data">'+
'<input type="text" name="field1">' +
var express = require('express')
, crypto = require('crypto');
var app = module.exports = express();
app.use(express.bodyParser());
app.use(express.cookieParser('shhhh, very secret'));
app.use(express.session());
app.set('view engine', 'ejs');
var http = require('http');
http.createServer(function (req, res) {
// set up some routes
switch(req.url) {
case '/':
// show the user a simple form
console.log("[200] " + req.method + " to " + req.url);
res.writeHead(200, "OK", {'Content-Type': 'text/html'});
res.write('<html><head><title>Hello Noder!</title></head><body>');
var http = require('http');
http.createServer(function (req, res) {
// set up some routes
switch(req.url) {
case '/':
// show the user a simple form
console.log("[200] " + req.method + " to " + req.url);
res.writeHead(200, "OK", {'Content-Type': 'text/html'});
res.write('<html><head><title>Hello Noder!</title></head><body>');
@dileephell
dileephell / gist:4084576
Created November 16, 2012 05:53
dileep form
var http = require('http');
http.createServer(function (req, res) {
// set up some routes
switch(req.url) {
case '/':
// show the user a simple form
console.log("[200] " + req.method + " to " + req.url);
res.writeHead(200, "OK", {'Content-Type': 'text/html'});
res.write('<html><head><link rel="stylesheet" type="text/css" href="style.css"><title>Hello Noder!</title></head><body>');
@dileephell
dileephell / gist:4085325
Created November 16, 2012 08:03
dileep css
var http = require('http');
var querystring = require('querystring');
var util = require('util');
http.createServer(function (req, res) {
// set up some routes
switch(req.url) {
case '/':
// show the user a simple form
console.log("[200] " + req.method + " to " + req.url);
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
module.exports.mongoose = mongoose;
module.exports.Schema = Schema;
//Connect to cloud database
var username = "Dileep"
var password ="******";
var db = require('../lib/db');
var UserSchema = new db.Schema({
username : {type: String, unique: true}
, password : String
})
var MyUser = db.mongoose.model('User', UserSchema);
// Exports
module.exports.addUser = addUser;
// Add user to database
function addUser(username, password, callback) {
var express = require('express')
, app = express()
, fs = require('fs');
// Routes
app.get('/form', function(req, res)
{
fs.readFile('./form.html', function(error, content)
{