Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

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.writeHead(200);
  response.end('Hello, World!');
}

const server = http.createServer(requestListener);
server.listen(3000);

//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

I'm also experiencing this error several months later

1 Answer

wildgoosestudent
wildgoosestudent
11,274 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

Ava Jones
Ava Jones
10,679 Points

Thank you! I also had this problem before I saw this post.