codecamp

Express Tutorial: The Local Library website

先决条件: 阅读简明介绍 对于以下文章,您还需要设置Node开发环境
目的: 介绍本教程中使用的示例应用程序,并允许读者了解将涵盖的主题。

概述

欢迎使用MDN"本地库"Express(Node)教程,其中我们开发了一个可用于管理本地库目录的网站。

在本系列教程文章中,您将:

  • Use the Express Application Generator tool to create a skeleton website and application.
  • Start and stop the Node web server.
  • Use a database to store your application's data.
  • Create routes for requesting different information, and templates ("views") to render the data as HTML to be displayed in the browser.
  • Work with forms.
  • Deploy your application to production.

您已经了解了一些这些主题,并简要地触及了其他主题。 到本教程系列的结尾,你应该知道足够自己开发简单的快速应用程序。

LocalLibrary网站

LocalLibrary 是我们将在本系列教程的过程中创建和发展的网站的名称。 正如您所期望的,网站的目的是为小型本地图书馆提供在线目录,用户可以在其中浏览可用的图书并管理其帐户。

这个例子被仔细选择,因为它可以缩放以显示我们需要的细节,并且可以用来显示几乎任何Express特性。 更重要的是,它允许我们提供您在任何网站所需的功能的指导路径:

  • In the first few tutorial articles we will define a simple browse-only library that library members can use to find out what books are available. This allows us to explore the operations that are common to almost every website: reading and displaying content from a database.
  • As we progress, the library example naturally extends to demonstrate more advanced website features. For example we can extend the library to allow new books to be created, and use this to demonstrate how to use forms, and support user authentication.

虽然这是一个非常可扩展的示例,它被称为本地库有一个原因 - 我们希望显示帮助您启动并运行Express的最低信息 很快。 因此,我们将存储有关图书,书籍副本,作者和其他重要信息的信息。 然而,我们不会存储图书馆可能借出的其他项目的信息,或提供支持多个图书馆网站或其他"大图书馆"功能所需的基础设施。

我被困,我在哪里可以得到源?

在您完成本教程时,我们将提供相应的代码段,供您在每个时间点进行复制和粘贴,并且还有其他代码,希望您能够自己扩展(通过一些指导)。

如果您遇到困难,可以在在Github上查找完整开发的网站版本

概要

现在您已了解了有关 LocalLIbrary 网站的详情,以及您将要学习的内容,现在是时候开始创建骨干计划 a>包含我们的例子。

Setting up a Node development environment
Express Tutorial Part 7: Deploying to production
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录
CSS

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }