There was an error while loading. Please reload this page.
0 parents commit d02de6aCopy full SHA for d02de6a
package.json
@@ -0,0 +1,12 @@
1
+{
2
+ "name": "rest-api-nodejs",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC"
12
+}
src/index.js
+import { createServer } from 'http'
+
+const server = createServer((req, res) => {
+ if (req.method === "GET" && req.url === "/") {
+ res.statusCode = 200
+ res.end()
+ }
+})
+server.listen(3001, () => {
+ console.log("Server listen on http://localhost:3001")
0 commit comments