“Express JS sert HTML” Réponses codées

Express Serve 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.User le public

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

Utilisez statique avec les expres

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

Express JS sert 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

Réponses similaires à “Express JS sert HTML”

Questions similaires à “Express JS sert HTML”

Plus de réponses similaires à “Express JS sert HTML” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code