Git Product home page Git Product logo

express-project's Introduction

express-project

搭建基于Express框架运行环境

* 安装express generator生成器
* 通过生成器自动创建项目
* 配置分析

安装

cnpm i -g express-generator
express --version        // 查看版本
express express-project  // 创建项目

image

cd express-project
cnpm install   // 安装依赖
node bin/www   // 运行

浏览器输入localhost:3000

image

更换模板引擎

express项目views文件夹内文件格式是.jade格式,若要改成HTML文件。

cnpm install ejs --save   //安装ejs  

app.js

var ejs = require('ejs');
app.engine('.html',ejs.__express);  // 设置html后缀模板引擎
app.set('view engine', 'jade'); 改成 app.set('view engine', 'html');


在views文件夹内建立index.html文件,重新启动express

node bin/www

localhost:3000

image

express-project's People

Contributors

ccyinghua avatar

Watchers

 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.