Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express'),
- cors = require('cors'),
- serveIndex = require('serve-index'),
- port = 9999
- app = express()
- app.use(cors())
- app.get('/', (req, res)=>{res.send(`<html><body><h1>Server running at port 9999</h1><h2><a href="/public">View files</a></h2></body></html>`)})
- app.use('/public', express.static('public'), serveIndex('public', {'icons': true}))
- app.listen(9999, ()=>console.log(`Server is listening at port ${port}`))
- {
- "name": "server",
- "version": "1.0.0",
- "description": "",
- "main": "app.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "author": "",
- "license": "ISC",
- "dependencies": {
- "cors": "^2.8.5",
- "express": "^4.16.4",
- "serve-index": "^1.9.1"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement