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 trialTurandeep Munday
6,047 PointsWhen i run the code workspace doesn't load it says workspace not available. I have tried different ports
//Problem: A simple way to look at a users badge count and javascript point from a web browser // Solution: Use node js to prform the profile lookups and serve our templates via http
// 1. create a web server
const http = require('http');
// const hostname = '127.0.0.1'; const port = 8080;
const server = http.createServer((request, response) => { r //after response.end then the browser will no longer be listening to the server thefore commented code will not work //response.write('This is after the end\n'); });
server.listen(port, () => {
console.log(Server running at http://treehouse-server:${port}/
);
});
// 2. handle HTTP route GET / and POST / i.e Home function homeRoute(request, response) { // if URL = '/' && GET // show Search esponse.statusCode = 200; response.setHeader('Content-Type', 'text/plain'); response.write("Header/n"); response.write("Search/n"); response.end('Footer/n'); }; //response.end('Hello World\n'); // if url = '/' && POST //redirect to /: username
// 3. Handle HTTP route GET /:username i.e .chalkers
//if url == "/...." //get JSON from treehouse // on "end" // show profile // on "error" // show error
// 4. Function tht handles the reading of the files and merge in values // read froom file and get a string // merge values in to string
Not loading a workspace - don't think it's the code - think it is to do with the workspace
3 Answers
Travis Alstrand
Data Analysis Techdegree Graduate 49,443 PointsHey there Turandeep Munday !
I went to this video and created a new Workspace from it and had no issues like what you mentioned in the title of your post here.
I copy/pasted what you've provided above and was hitting a lot of errors involving typos, missing characters and sections being commented out that were needed. For example, missing backticks in your template literal for the console.log
statement on line 11, a random r
on line 9, line 7 being commented out etc.
If you're not getting these types of errors returned, I would try deleting the Workspace and starting a fresh new one as I have not experienced any "Workspace not available" errors when trying on my end.
Placing your code within three backticks makes it much easier to read when formatting so that it appears like this...
const example = "this is a codeblock example in markdown";
There is the "Markdown Cheatsheet" link provided with formatting options and providing a Snapshot of your Workspace may be helpful as well so that we can see exactly what it is you're working with and try to further debug the issue.
You can see how to create a Snapshot in this video
Turandeep Munday
6,047 PointsHi Travis - I am still seeing the issue? its not even loading the code in the port. I am just getting bad gateway, would you be able to help to resolve this?
Failed to load resource: the server responded with a status of 502 (Bad Gateway) port-3000-w5t9ytv1me.treehouse-app.com/:1 Failed to load resource: the server responded with a status of 502 (Bad Gateway)
Turandeep Munday
6,047 PointsThis was after deleting workspace and creating a new one. Additionally, i had to use new example code which initialised everything as variables before starting.
Travis Alstrand
Data Analysis Techdegree Graduate 49,443 PointsVery strange! The only way I've come across a 502 is if I try to "open a preview" before running node app.js
in the Workspace's Console first. Are you running this command?
If so, I would maybe try clearing your cache or try opening it within a different browser. Please keep me updated!