Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Build a Simple Dynamic Site with Node.js Creating a Simple Server in Node.js Creating a Simple Server

Caleb Newell
Caleb Newell
12,330 Points

Workspace preview error

When I try to preview this code in workspaces it just gives me the error 'Workspace Unavailable This is a preview link for a Treehouse Workspace that is not currently active.

If you are the workspace owner, you can launch it again via the Treehouse site.' Does anyone know what I am doing wrong? (Or if something is wrong with treehouse.)

//Problem: We need a simple way to look at a users badge count and javascript point from a web browser //Solution: Use node.js to perform the profile lookups and serve our template via HTTP

//1. Create a webserver

const http = require('http');

const requestListener = function (request, response) {
  response.end('Hello, World!');

const server = http.createServer(requestListener);

//2. Handle HTTP route GET / and POST / i.e. home //if url == "/" && GET //show search //if url == "/" && POST //redirect to the user name

//3. Handle HTTP route for GET /:username i.e. /calebnewell //if url == "/....." //get json from trehouse //on end //show proflie //on error //show error

//4. functionn the handles the reading of files and merge in values //read from file and get a string //merge values into a string

Lars Holmberg
Lars Holmberg
19,949 Points

I'm also experiencing this error several months later

1 Answer

11,110 Points

I've just tried your code and it worked for me. I suspect that you may have had another server running.

In console: control + c then node app.js