Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9147481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:59:54+00:00 2026-06-17T10:59:54+00:00

I am using the simple as possible web server straight off of the flatiron

  • 0

I am using the simple as possible web server straight off of the flatiron website and wanted to experiment testing it with vows. I can get the tests to pass but the test never exits. I assume this is because I the flatiron server never shuts down. How do I shut the server down or there a better way to do simple http tests with another technology?

server.js

var flatiron = require('flatiron'),
    app = flatiron.app;

app.use(flatiron.plugins.http);

app.router.get('/', function () {
  this.res.writeHead(200, { 'Content-Type': 'text/plain' });
  this.res.end('Hello world!\n');
});

app.start(8000);

server-test.js

var request = require('request'),
    vows = require('vows'),
    assert = require('assert');

vows.describe('Hello World').addBatch({
  "A GET to /": {
    topic: function () {
      server = require('../server');
      request({
        uri: 'http://localhost:8000',
        method: 'GET'
      }, this.callback)
    },
    "should respond with 200": function (error, response, body) {
      assert.equal("Hello world!\n", body);
    },
    teardown: function (topic) {
      // *********************************
      // Do something to shutdown flatiron
      // *********************************
    }
  }
}).export(module);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:59:55+00:00Added an answer on June 17, 2026 at 10:59 am

    You need to export the server to be able to shut it down.
    Simply add this in server.js : module.exports = app;

    Now, you can use server var to shut flatiron down. The docs are not too verbose on how to close it, but I manage to have it closed with app.server.close().
    Here are the files :

    server.js

    var flatiron = require('flatiron'),
        app = flatiron.app;
    
    module.exports = app;
    
    app.use(flatiron.plugins.http);
    
    app.router.get('/', function () {
      this.res.writeHead(200, { 'Content-Type': 'text/plain' });
      this.res.end('Hello world!\n');
    });
    
    app.start(8000);
    

    server-test.js

    var request = require('request'),
        vows = require('vows'),
        assert = require('assert');
    
    var app = require('./server');
    
    vows.describe('Hello World').addBatch({
      "A GET to /": {
        topic: function () {
          request({
            uri: 'http://localhost:8000',
            method: 'GET'
          }, this.callback)
        },
        "should respond with 200": function (error, response, body) {
          assert.equal("Hello world!\n", body);
        },
        teardown: function (topic) {
          app.server.close();
        }
      }
    }).export(module);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to create a simple web browser for Android by using Monodroid?
Can anyone share simple sample of using Semaphore? If it's possible a sample of
How can I know that, my application (using LDAP/exchange server and Exchange Web Service)
As a project, I wanted to build a personal website using Java for the
Possible Duplicate: Consuming a Web service using Javascript Please note that I'm still getting
My question is pretty simple: If you have two web-application components: Server-side (secret-capable) code
I made a simple web crawler using PHP (and cURL). It parses rougly 60
I'm looking for a simple Python framework/library for creating a website run using PyPy.
I am writing a server application using Tornado web server . Application works with
I'm an ASP.NET web part novice. I've built a few simple ones using only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.