Assignment 7: Hosting a Past Assignment with Express

Due: Tuesday, 11/17/26, before class.

Goal

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).

File and Folder Setup

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.

Requirements

  1. Pick a past assignment
    Any of Assignments 3 through 6 is a good choice, because they have JavaScript. Copy all of its files into public/, keeping any subfolders (like images/) the same.
  2. Install Express
    In the terminal, 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"
      }
    }
  3. Don't push node_modules
    Make a file called .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.
  4. Write server.js with Express
    Use express.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;
  5. Test it on your computer first
    Run 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).
  6. Host it on Render
    Commit, push, and make a new Web Service, following Step 3 of the Render setup. The only setting that changes is Root Directory:
    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)
  7. Put your Render link in README.md
    Make a file called README.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.
  8. Code comments
    Add your own HAND-WRITTEN comments to server.js explaining what each part does.
  9. BONUS: A route of your own
    Add at least one 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.

Things That Will Trip You Up

A Note on Generative AI

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.

What to Submit

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.