编程代写 INFO 30005

INFO 30005
Web Information Technologies
Introduction to

Copyright By PowCoder代写 加微信 powcoder

Recap: responding to HTTP requests
HTTP requests
HTTP responses
for example…
GET path HTML output call to REST API JSON output
How can we set up an app to do this?
• file system • database

We’ll use Node.js to program our web apps

Install node
Mac / Windows
download installer
$ sudo apt install nodejs $ sudo apt install npm

Using Node
VS Code terminal

Anatomy of a server
HTTP requests
HTTP responses

Very simple server
Use Node’s HTTP module
callback function listen
Run script
prompt or VSC terminal $ nodemon [filename.js] connect via web browser

Requests and Responses
HTTP request A HTTP response A
HTTP request B HTTP response B

Inspecting requests
properties of REQ
method url
properties of URL
pathname search

Respond to requests
switch statement
path, method, query string … note growing complexity

Respond with static files
switch statement
if valid, call sendFile
uses fs module
read requested HTML file sent contents to browser or show error message

On to Express …
this server ‘works’
but routine things are complex manually checking the Request
Express.js
very widely used makes things easier next lecture

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com