0

i am looking to code like it is 1999.

I want to develop a SIMPLE Node server to server one page: index.html styled with styles.css and displaying image.png.

Google has not shown me a simple result. If your answer is 'Check out this cool third party software/library/npm package', that is NOT what i am looking for. I am trying to find an answer that does not require typing 'npm i -S foo'.

I just want to use the built in http module to serve a basic html file, but every example and answer is find uses template engines, express, or some other additional packages. I am not looking to get better at googling packages. I am not trying to serve a 'Hello World' string. I am not trying to code a fileserver. I am looking to get better at understanding the rock bottom basics. What is the most basic method with the least dependencies? That is what i seek to learn.

The closest i have come still requires express

var express = require('express')
var http = require('http')
var app = express()

app.use(express.static(__dirname + '/static'))

http.createServer(app).listen(8080)

but results in this error

Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”).

Looking to learn, so any advice appreciated, tia~

milo
  • 47
  • 3
  • Possible duplicate of [Content Security Policy: The page's settings blocked the loading of a resource](https://stackoverflow.com/questions/37298608/content-security-policy-the-pages-settings-blocked-the-loading-of-a-resource) – jmargolisvt Nov 06 '19 at 03:17
  • No, this is not a duplicate. CSP is not the question; simple http server is the question. – milo Nov 06 '19 at 03:43
  • This looks pretty basic, is that what you were thinking? [Create HTTP Web Server in Node.js: Complete Tutorial](https://www.guru99.com/node-js-create-server-get-data.html) – EGC Nov 06 '19 at 04:02
  • Alternatively, it looks like this guy has had a go at building his own basic file server here [Node.js quick file server (static files over HTTP)](https://stackoverflow.com/a/29046869/11700321) – EGC Nov 06 '19 at 04:04
  • @EGC: thanks, i saw both if those in my google searching. The first serves a 'Hello World' string, not a local html page. If that tut continued for one more step that would be it. The second is a file server, not an html server. – milo Nov 06 '19 at 21:39

0 Answers0