DEV Community

Cover image for Day 3
Brix Mavu
Brix Mavu

Posted on

3 2

Day 3

Requirements

  • NodeJS installed

To do

Inside Workspace folder create folder day 3

mkdir day3

Enter day3 folder

cd day3

Running Express

Run commands inside terminal to install express

  1. npm init -y

  2. npm i express

  3. touch app.js

  4. copy and paste Hello World Example
    inside app.js file

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
  res.send('Hello World!')
})

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})
Enter fullscreen mode Exit fullscreen mode

Inside your terminal type

node app.js

In browser go localhost:3000

Static Files e.g. html, CSS and JavaScript

Inside day3 folder - create new folder - public

mkdir public

Inside public paste project files from day 2.

Files

  • index.html
  • style.css
  • script.js

Inside app.js remove

app.get('/', (req, res) => {
  res.send('Hello World!')
})
Enter fullscreen mode Exit fullscreen mode

and add

const path = require('path')
app.use('/', express.static(path.join(__dirname, 'public')))

Enter fullscreen mode Exit fullscreen mode

Learn more about express.static

The code should look more like this

const express = require('express')
const path = require('path')

const app = express()
const port = 3000

app.use('/', express.static(path.join(__dirname, 'public')))

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})
Enter fullscreen mode Exit fullscreen mode

Check again localhost:3000

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more