Code Monkey home page Code Monkey logo

nodejs-express-app's Introduction

nodejs-express-app

How to build a simple Node.js and Express app by creating a interface and server API

יצירת שרת Node.js עם Express

  1. איתחול פרוייקט
  2. יצירת אינדקס
  3. התקנת נודמון
  4. התקנת אקספרס
  5. יצירת גיט איגנור
  6. בניית טמפלט באינדקס

/* Required External Modules */

/*** App Variables*/

/*** App Configuration*/

/*** Routes Definitions*/

/*** Server Activation*/

  1. לייבא מודולים
  2. app יצירת אובייקט
  3. הגדרת פורט :

const port = process.env.PORT || "8000";

ראטוניג

  1. יצירת בקשה בראטוניג :

app.get("/", (req, res) => { res.status(200).send("WHATABYTE: Food For Devs"); });

  1. יצירת ליסנר app.listen(()=>{})
  2. הרצה

Pug files

  1. התקנת פאג
  2. יצירת קובצי פאג :

block variables doctype html html head meta(charset="utf-8") meta(name="viewport", content="width=device-width, initial-scale=1, shrink-to-fit=no") body div#root block layout-content div#footer //////////////////////////////////////////

extends layout block layout-content div.View

  1. שימוש ב views :

app.set("views", path.join(__dirname, "views"));

  1. שימוש במנוע פאג:

app.set("view engine", "pug");

  1. יצירת בקשה בראוטינג לאינדקס :

res.render("index", { title: "Home" });

browser-sync

  1. התקנת מרנדר לייב : browser-sync
  2. יצירת פקודה :
"ui": "browser-sync start --proxy=localhost:8000 --files='**/*.css, **/*.pug, **/*.js' --ignore=node_modules --reload-delay 10 --no-ui --no-notify"

Public files

  1. שימוש בסטטיק להעלאת קבצי עזר:

app.use(express.static(path.join(__dirname, "public")));

  1. יצירת ספריה ציבורית וקבצי עזר
  2. הוספת תמונה

POST and body-parser

  1. יצירת דף נוסף
  2. יצירת בקשת POST בראוטינג לדף החדש
  3. התקנת body-parser
  4. הגדרת body-parser לשימוש על ידי app.use
  5. שליחת המידע שהתקבל מה request.body כתשובה
  6. שליחת המסך החדש והמידע שהתקבל כתשובה

nodejs-express-app's People

Contributors

jeck99 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.