Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

TUGAS PEMROGRAMAN WEB

Pemrograman Web – TIK3032_C :


Shallomikha Hanna Lumintang
20021106125

PROGRAM STUDI TEKNIK INFORMATIKA


JURUSAN TEKNIK ELEKTRO
UNIVERSITAS SAM RATULANGI MANADO
Client side
1+1 2 console.log('Hello

World'); VM159:1 Hello

World undefined

alert('Hello World')

undefined document

#document<!DOCTYPE html><html dir="ltr" lang="en" class="focus-outline-visible"><head>…


</head><body>…</body></html>
'Mikha'.toUpperCase()
'Mikha'

-----------------------------------------------------------------------------------------------------

Server side

Microsoft Windows [Version 10.0.19044.1645]

(c) Microsoft Corporation. All rights reserved.

C:\Users\acer>node

Welcome to Node.js v16.15.0.


Type ".help" for more information.

> console.log('Hello World !!')

Hello World !! undefined

> 3+8
11

> 4+20

24

>

Vsc

1. hello world
console.log('Hello Worrld')
PS C:\Kuliah\SMTR 4\PEMROGRAMAN WEB> node hello.js
Debugger attached.

Hello Worrld

Waiting for the debugger to disconnect...

PS C:\Kuliah\SMTR 4\PEMROGRAMAN WEB>

PS C:\Kuliah\SMTR 4\PEMROGRAMAN WEB> node hello.js


Debugger attached.

Hello Worrld

Waiting for the debugger to disconnect...

2. require('http')
const http = require('http')
const hostname =
'127.0.0.1' const port =
3000
const server = http.createServer((req, res) =>
{ res.statusCode = 200
res.setHeader('Content-Type',
'text/plain') res.end('Hello World\n')
}) server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`)
})

PS C:\Kuliah\SMTR 4\PEMROGRAMAN WEB> node apps.js


Debugger attached.
Server running at http://127.0.0.1:3000/

3. require file js lain


//const getNotes = function() {
//return "Your Notes.."
//} const tambah =
function(a,b){ return a+b
} module.exports =
tambah

const get = require('./app2')

//const note = get()


console.log(get(5,7))

PS C:\Kuliah\SMTR 4\PEMROGRAMAN WEB> node app3.js

Debugger attached.
12

Waiting for the debugger to disconnect...


PS C:\Kuliah\SMTR 4\PEMROGRAMAN WEB>

const get = require('./app3')


const note =
get()

console.log(note)

const getNotes = function (){


return "Mikayy here"
} module.exports =
getNotes

PS C:\Kuliah\SMTR 4\PEMROGRAMAN WEB> node app2.js

Debugger attached.

chiaa here

Waiting for the debugger to disconnect...

PS C:\Kuliah\SMTR 4\PEMROGRAMAN WEB>

4. require fs writefilesync
const fs = require('fs')
fs.writeFileSync("test.txt",'hii.. how are u ?')

5. require fs appendfilesync
fs.appendFileSync("test.txt",' have a nice day')

PS C:\Kuliah\SMTR 4\PEMROGRAMAN WEB> node app4.js

Debugger attached.
Waiting for the debugger to disconnect...

PS D:\Kuliah\SMTR 4\PEMROGRAMAN WEB>

6. require validator
const val = require('validator')
console.log(val.isEmail('g@student.ac.id'))

console.log(val.isDate('2002/12/30'))
console.log(val.isIMEI('245361903245612'))
console.log(val.isDecimal('0.1'))

PS C:\Kuliah\SMTR 4\PEMROGRAMAN WEB> node app5.js

Debugger attached.

true true

true true

Waiting for the debugger to disconnect...


PS C:\Kuliah\SMTR 4\PEMROGRAMAN WEB>

7. require express
- index.html
- style.css

- app.js
- tampilan light bulb

You might also like