top button
Flag Notify
Site Registration

Can't load the html page from node.js

+1 vote
555 views

History / Context: Display the html page from node.js

Problem Statement: The database is connected, but when i am running it in local host it is showing 'Cannot GET'.

Expected Result: It should load the html page from node.js

Present Output: Database is connected but cant load the page of html

Attach Code:

filter.js

var express = require('express'),
    filter = express(),
    server = require('http').createServer(filter),
    io = require('socket.io').listen(server),
    mongoose = require('mongoose');

server.listen(7550, '127.0.0.1');
console.log('Server running at http://127.0.0.1:7550/');

mongoose.connect('mongodb://localhost/filter_CheckBoxSchema', function (err) {
    if (err) {
        console.log('What happened!!!');
    } else {
        console.log('Connected to mongodb!');
    }
});

var filter_CheckBoxSchema = mongoose.Schema({
    category: { name: String, type: Boolean, default: false },
    created: { type: Date, default: Date.now }
});

var Filter = mongoose.model('Filter', filter_CheckBoxSchema);
filter.get('example.html', function (req, res) {    
    new Filter({
        name: req.body.name,
        type: req.body.gender,

    }).save(function (err, doc) {
        if (err) {
            throw err;
        }
        else
            res.send('Successfully inserted!!!');
    });
});

example.html

<html>
    <head>
        <title>
            Please enter your details
        </title>
    </head>
    <body>
        <h3>Please enter your details</h3>
        <p>Please register below!!!</p>
        <form action="filter.js" method="POST">
            Name: <input type="text" name="Name" />
            <br /><p></p>
            Gender:
            <br />
            <input type="radio" name="gender" /> Male
            <br />
            <input type="radio" name="gender" /> Female
            <p></p>
            Interest: (Check all that apply)
            <p>
            </p>
            <input type="checkbox" name="breakfast" /> Breakfast
            <br />
            <input type="checkbox" name="Lunch" /> Lunch
            <br />
            <input type="checkbox" name="Evening Snacks" /> Evening Snacks
            <br />
            <input type="checkbox" name="Dinner" /> Dinner
            <br />
            <p></p>
            <input type="submit" name="submit" value="Register!!!" />
        </form>
    </body>
</html>
posted Aug 5, 2014 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button
It seems to be identical of http://stackoverflow.com/questions/25117967/cant-load-the-html-page-from-node-js

Just check if the same link solves your problem. Else comment and provide some logs.

...