Giter Site home page Giter Site logo

multiple-express-examples's Introduction

Examples

basic - Hello World

Generic express app with a single route: /

Renders "Hello!" when viewed in a browser.

basic-template - Hello world + template

Uses express-es6-template-engine to show page with "Hello, template!"

template-static - Hello world + template + static

Adds the express.static() middleware for serving static content. (helmet is disabled for local development. On my machine, it tried to pull up the static assets using https, which is only for a live site.)

layout-template - Template with "layout" (shorthand to include header and footer)

The header and footer can be "sprinkled" into the res.render():

const layout = {
    partials: {
        header: '/partials/header',
        footer: '/partials/footer'
    }
};

app.get('/', (req, res) => {
    res.render('home', {
        ...layout,
        locals: {
            message: "Hello, template with static assets!",
            imageUrl: '/images/oakley.jpg'
        }
    })
});

master-detail

Shows a list of products.

Each product links to a product details page.

master-detail-controllers-models

Reorganizes code so that it's not all in the index.js

master-detail-controllers-models-router

Moves routing to a separate file.

master-detail-controllers-models-router-pagination

Adds model, controller, and route for viewing 25 products at a time.

Displays page links for navigating from page to page.

Updates detail.html to go back in the browser history (instead of navigating to /products/).

master-detail-controllers-models-multiple-routers

Adds employee list at route /employees Adds employee detail at route /employees/:id

form-basic

Shows 3-part flow for handling forms:

  • app.get(): show a form
  • app.post(): process a form
  • res.rediret() to another page

multiple-express-examples's People

Contributors

radishmouse 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.