Due: Tuesday, 11/17/26, before class.
In the Render setup, you got a tiny server running on Render. In
class on 11/10, we saw that one line of Express, express.static("public"), turns a
folder of files into a working website. For this assignment, you'll put those two things together:
pick one of your past assignments, serve it with your own Express server, and host that server on
Render.
Your assignment already works on GitHub Pages. The difference is that this time, your own server is the one sending the files. That's the starting point for everything we build next, where the server will also send and save data.
Start from the example from class:
The Same Server in Express (server.js,
package.json, and a public/ folder).
Make a new 07-express-hosting folder in your assignments folder. Folder and
file names must match exactly:
csc336-fall2026/
└── assignments/
└── 07-express-hosting/
├── README.md
├── .gitignore
├── package.json
├── package-lock.json
├── server.js
└── public/
├── index.html
├── style.css
└── script.js (and whatever other files your assignment uses)
Copy your past assignment's files into public/. Don't move them: the
original should keep working on GitHub Pages.
public/, keeping any subfolders (like images/) the same.
cd into your 07-express-hosting folder and run:
npm install express
This makes package.json, package-lock.json, and a
node_modules folder. Then open package.json and add
"type": "module" so you can use import. It should look like this:
{
"type": "module",
"dependencies": {
"express": "^5.3.0"
}
}
node_modules.gitignore in 07-express-hosting with this one line in
it:
node_modules
node_modules can have thousands of files in it. Render doesn't need it from you,
because its build command, npm install, downloads everything listed in
package.json itself.
server.js with Expressexpress.static("public") to serve your files, like the class example. One change
from the class example: Render picks the port, so use the same line as your Render setup server.
const port = process.env.PORT || 3000;
node server.js and visit
http://localhost:3000. Your assignment should
look and work exactly like it does on GitHub Pages. Open the Network tab and make sure nothing is
red (a red line is a file the browser asked for and didn't get).
| Field | What to put |
|---|---|
| Root Directory | assignments/07-express-hosting |
| Build Command | npm install |
| Start Command | node server.js |
| Instance Type | Free (don't add a credit card) |
README.mdREADME.md in 07-express-hosting with your Render link
in it, like:
https://yourname-express-hosting.onrender.com
GitHub shows this file when someone opens your folder, which is how I'll find your server.
server.js explaining what
each part does.
app.get route, like /mike in the class example, that
sends back something that isn't a file. For example, /about could send a sentence
about which assignment this is, or /time could send the server's current time.
node server.js from inside 07-express-hosting.
express.static("public") looks for public in the folder you ran the
command from. If you run it from somewhere else, every page is "Cannot GET /".
../../images/cat.png, that file isn't in public/, and your server can't
send anything outside public/. Copy the file into public/ and fix the
path.
Do not use ChatGPT, Copilot, Claude, or any other generative AI tool to write any part of this assignment. Whatever you do, remember that your goal should be to understand 100% of the code that you turn in.
Nothing to submit directly. Push your 07-express-hosting folder, make sure your Render link
works, and make sure that link is in your README.md.