Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Steve Griffith prof3ssorSt3v3

🎯
Focusing
Block or report user

Report or block prof3ssorSt3v3

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@prof3ssorSt3v3
prof3ssorSt3v3 / app.js
Created Jan 25, 2020
Express Sending Responses of various types from YouTube tutorial.
View app.js
"use strict";
// https://expressjs.com/en/4x/api.html#res
const express = require("express");
const app = express();
const port = process.env.port || 3000;
app.set("view engine", "pug");
app.set("views", process.cwd() + "/views");
app.get("/", (req, res) => {
//handle route: get requests for "/"
View app.js
"use strict";
const data = require("./data"); //data.channels[n].id .name .last_update
const express = require("express");
const app = express();
app.use(express.json());
app.get("/api/channel", (req, res) => {
//return the list of channels
// respond with a 200
View app.js
//Understanding Middleware
"use strict";
const express = require("express");
const app = express();
const cors = require("cors");
const { sup, how } = require("./middle");
app.use(sup);
app.use(cors());
View express-requests.js
"use strict";
const express = require("express");
const app = express();
app.get("/", (req, res) => {
console.log(req.headers);
console.log(req.url);
console.log(req.ip);
console.log(req.hostname);
console.log(req.method); //get
View app.js
"use strict";
const express = require("express");
const app = express();
app
.get("/", (req, res) => {
console.log(req.url);
res.send("<h1>Hello</h1>"); //determine the content-type automatically
})
.post("/", (req, res) => {})
View app.js
//How to export and require modules with NODE JS
const fs = require("fs");
//const f = require("./module1.js")
// const mod = require("./module1");
const { f, P } = require("./module1");
//const y = require("./module2/bubba.js");
//const y = require("./module2/bubba");
const y = require("./module2");
View str-arr.js
//treating Strings like Arrays
let log = console.log;
let str = "Ragnar Lothbrok";
// log(str[0], str[1]);
// log(str.charAt(0), str.charAt(1));
let arr = str.split("");
let arr2 = Array.from(str);
//log(arr, arr2);
// log(arr[0], arr2[1]);
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Static Server</title>
<link rel="stylesheet" href="./main.css" />
</head>
<body>
View literals.js
let obj1 = {
a: "this",
b: "is",
c: "an",
d: "object",
e: "literal"
};
let obj2 = new Object(["object", "contructor", "one"]); // new Array("", "", "")
let obj3 = new Object({ an: "object", literal: "again" });
let obj4 = new Object(obj1.a); // new Object("some string") new String("asdfas")
View clip-path.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>CSS clip-path Property</title>
<style>
html {
font-size: 12px;
You can’t perform that action at this time.