2018-08-27 server side farmeworks

Introduction to Express

#Introduction to Express

* What is a framework? how is it different from a library?

Frameworks are code that someone else wrote usually a lot of people wrote because it's a lot more code that we can use inside of our application.

Both library and framework are external code that you're including in your won applicaiton, but library is something that you're in control of,

if you want to use a library, you can use one method, ten method , it's up to us which parts of it we use. we might only use a few of the method s for

animations or we might use 100 different methods.

With a framework on the other hand, we give up a little bit of control where if we use a framework like the one we're going to use which is Express

we have some decisions that have been made for us that we have to abide by in order to use the framework.

* Whar is Express?

framework of web development

flask for python, Django for Python, rails for Ruby,Sinatra for Ruby

* Why are we using Express?

most popular

very light wight framework

unopinionated means flexible


#Our First Express APP

*Review an exisiting app(DogDemo)

*Review Http response/requese lifecycle

*create our own simple Express APP

#NPM Init and package

.json*Use the '--save'flag to install package

it will take the package name and version in automatically save it into our package.json

*Explain what the package.json file does

this file holds metadata relevant to the project 

*use 'npm init'to create a new package.json



#More Routing !

*show the '*'route matcher

when we use the star instead of a route definitiaon, it will match anything that comes in at all


*Write routes containing route paramters

define an pattern in a route

app.get("/r/:subredditName/comments/:id/:title");



*Discuss route order

if we put the star up top, no other routes will run below it

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,449评论 0 10
  • 在6666年,8月31日,今天我刚拿起没有动的作业。 我的心里像热锅上的蚂蚁,我想,完了,完了完啦,我...
    张墨涵阅读 319评论 2 1
  • 五一放假和家人去郴州小东江游玩。导航导的路线极其恶劣,加暴雨,崎岖山路,一直想退缩,但还是坚持走下去了。最后到了目...
    zengjoy阅读 357评论 0 1
  • 愿以此功德。庄严佛净土。 上报四重恩。下济三途苦。 若有见闻者。悉发菩提心。 尽此一报身。同生极乐国。 南无大悲观...
    天牛and恩恩成长记阅读 129评论 0 0