“Ekspres JS melayani html” Kode Jawaban

Express melayani html

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

const app = express()

const port = process.env.PORT || 3000
const publicDirectoryPath = path.join(__dirname, '../public')

app.use(express.static(publicDirectoryPath))

app.listen(port, () => {
    console.log(`Server is up on port ${port}!`)
})
Thor

App.Use Public

app.use(express.static('public'))
app.use(express.static('files'))
Testy Tamarin

Gunakan statis dengan ekspres

app.use(express.static('directoryName'))
#store the files in the directory as if you were making a website without express
Encouraging Elk

Ekspres JS melayani html

const express = require('express')

const app = express()
app.use(express.static('public'))

app.listen(port, () => {
    console.log(`Server is up on port ${port}!`)
})
SamuraiR4cc00n

Jawaban yang mirip dengan “Ekspres JS melayani html”

Pertanyaan yang mirip dengan “Ekspres JS melayani html”

Lebih banyak jawaban terkait untuk “Ekspres JS melayani html” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya