Showing
106 changed files
with
0 additions
and
1018 deletions
1 | -// Please implements multiplication tables (구구단) |
1 | -var a = 33; | ||
2 | -var b = 10; | ||
3 | -var c = "Test"; | ||
4 | -console.log("a + b = "); | ||
5 | -result = a + b; | ||
6 | -console.log(result); | ||
7 | - | ||
8 | -console.log("a - b = "); | ||
9 | -result = a - b; | ||
10 | -console.log(result); | ||
11 | -console.log("a / b = "); | ||
12 | -result = a / b; | ||
13 | -console.log(result); | ||
14 | -console.log("a % b = "); | ||
15 | -result = a % b; | ||
16 | -console.log(result); | ||
17 | -console.log("a + b + c = "); | ||
18 | -result = a + b + c; | ||
19 | -console.log(result); | ||
20 | -a = a++; | ||
21 | -console.log("a++ = "); | ||
22 | -result = a++; | ||
23 | -console.log(result); | ||
24 | -b = b--; | ||
25 | -console.log("b-- = "); | ||
26 | -result = b--; | ||
27 | -console.log(result); |
1 | -var a = 33; | ||
2 | -var b = 10; | ||
3 | -console.log("Value of a => (a = b) => "); | ||
4 | -result = (a = b); | ||
5 | -console.log(result); | ||
6 | -console.log("Value of a => (a += b) => "); | ||
7 | -result = (a += b); | ||
8 | -console.log(result); | ||
9 | -console.log("Value of a => (a -= b) => "); | ||
10 | -result = (a -= b); | ||
11 | -console.log(result); | ||
12 | -console.log("Value of a => (a *= b) => "); | ||
13 | -result = (a *= b); | ||
14 | -console.log(result); | ||
15 | -console.log("Value of a => (a /= b) => "); | ||
16 | -result = (a /= b); | ||
17 | -console.log(result); | ||
18 | -console.log("Value of a => (a %= b) => "); | ||
19 | -result = (a %= b); | ||
20 | -console.log(result); |
1 | -var a = 2; // Bit presentation 10 | ||
2 | -var b = 3; // Bit presentation 11 | ||
3 | -console.log("(a & b) => "); | ||
4 | -result = (a & b); | ||
5 | -console.log(result); | ||
6 | - | ||
7 | -console.log("(a | b) => "); | ||
8 | -result = (a | b); | ||
9 | -console.log(result); | ||
10 | - | ||
11 | -console.log("(a ^ b) => "); | ||
12 | -result = (a ^ b); | ||
13 | -console.log(result); | ||
14 | - | ||
15 | -console.log("(~b) => "); | ||
16 | -result = (~b); | ||
17 | -console.log(result); | ||
18 | - | ||
19 | -console.log("(a << b) => "); | ||
20 | -result = (a << b); | ||
21 | -console.log(result); | ||
22 | - | ||
23 | -console.log("(a >> b) => "); | ||
24 | -result = (a >> b); | ||
25 | -console.log(result); |
1 | -var a = 10; | ||
2 | -var b = 20; | ||
3 | -console.log("(a == b) => "); | ||
4 | -result = (a == b); | ||
5 | -console.log(result); | ||
6 | - | ||
7 | -console.log("(a < b) => "); | ||
8 | -result = (a < b); | ||
9 | -console.log(result); | ||
10 | -console.log("(a > b) => "); | ||
11 | -result = (a > b); | ||
12 | -console.log(result); | ||
13 | -console.log("(a != b) => "); | ||
14 | -result = (a != b); | ||
15 | -console.log(result); | ||
16 | -console.log("(a >= b) => "); | ||
17 | -result = (a >= b); | ||
18 | -console.log(result); | ||
19 | -console.log("(a <= b) => "); | ||
20 | -result = (a <= b); | ||
21 | -console.log(result); |
1 | -var age = 20; | ||
2 | -if( age > 18 ) { | ||
3 | - console.log("Qualifies for driving"); | ||
4 | -} | ||
5 | - | ||
6 | -var age = 15; | ||
7 | -if( age > 18 ) { | ||
8 | - console.log("Qualifies for driving"); | ||
9 | -} else { | ||
10 | - console.log("Does not qualify for driving"); | ||
11 | -} | ||
12 | - | ||
13 | - | ||
14 | -var book = "maths"; | ||
15 | -if( book == "history" ) { | ||
16 | - console.log("History Book"); | ||
17 | -} else if( book == "maths" ) { | ||
18 | - console.log("Maths Book"); | ||
19 | -} else if( book == "economics" ) { | ||
20 | - console.log("Economics Book"); | ||
21 | -} else { | ||
22 | - console.log("Unknown Book"); | ||
23 | -} |
1 | -var grade='A'; | ||
2 | -console.log("Entering switch block"); | ||
3 | - | ||
4 | -switch (grade) | ||
5 | -{ | ||
6 | - case 'A': | ||
7 | - console.log("Good job"); | ||
8 | - break; | ||
9 | - | ||
10 | - case 'B': | ||
11 | - console.log("Pretty good"); | ||
12 | - break; | ||
13 | - | ||
14 | - case 'C': | ||
15 | - console.log("Passed"); | ||
16 | - break; | ||
17 | - | ||
18 | - case 'D': | ||
19 | - console.log("Not so good"); | ||
20 | - break; | ||
21 | - | ||
22 | - case 'F': console.log("Failed"); | ||
23 | - break; | ||
24 | - | ||
25 | - default: | ||
26 | - console.log("Unknown grade") | ||
27 | -} | ||
28 | - | ||
29 | -console.log("Exiting switch block"); | ||
30 | - | ||
31 | - | ||
32 | - | ||
33 | -switch (grade) | ||
34 | -{ | ||
35 | - case 'A': | ||
36 | - console.log("Good job"); | ||
37 | - | ||
38 | - case 'B': | ||
39 | - console.log("Pretty good"); | ||
40 | - | ||
41 | - case 'C': | ||
42 | - console.log("Passed"); | ||
43 | - | ||
44 | - case 'D': | ||
45 | - console.log("Not so good"); | ||
46 | - | ||
47 | - case 'F': | ||
48 | - console.log("Failed"); | ||
49 | - | ||
50 | - default: | ||
51 | - console.log("Unknown grade"); | ||
52 | - | ||
53 | -} | ||
54 | - | ||
55 | -console.log("Exiting switch block"); |
1 | -var name = "Ali"; | ||
2 | -var money; | ||
3 | -money = 2000; | ||
4 | - | ||
5 | -console.log("my name is " + name); | ||
6 | -console.log("my money is " + money); | ||
7 | - | ||
8 | -var myVar = "global"; // Declare a global variable | ||
9 | -function checkscope( ) { | ||
10 | - var myVar = "local"; | ||
11 | - // Declare a local variable | ||
12 | - console.log("print myVar " + myVar); | ||
13 | -} | ||
14 | - | ||
15 | -console.log("print myVar " + myVar); | ||
16 | -checkscope(); |
1 | -var count = 0; | ||
2 | -console.log("Starting Loop "); | ||
3 | - | ||
4 | -while (count < 10) { | ||
5 | - console.log("Current Count : " + count); | ||
6 | - count++; | ||
7 | -} | ||
8 | -console.log("Loop stopped!"); | ||
9 | - | ||
10 | - | ||
11 | -var count = 0; | ||
12 | -console.log("Starting Loop"); | ||
13 | -do { | ||
14 | - console.log("Current Count : " + count); | ||
15 | - count++; | ||
16 | -} while (count < 5); | ||
17 | -console.log ("Loop stopped!"); |
1 | -function addPrice(amount) { | ||
2 | - this.price = amount; | ||
3 | -} | ||
4 | -function book(title, author) { | ||
5 | - this.title = title; | ||
6 | - this.author = author; | ||
7 | - this.addPrice = addPrice; | ||
8 | -} | ||
9 | - | ||
10 | -var bookList = new Array(new book("Perl1", "Mohtashim"),new book("Smith", "Mohtashim"),new book("Carl", "Mohtashim"),new book("Perl2", "Mohtashim")); | ||
11 | - | ||
12 | -console.log(bookList); | ||
13 | -console.log("After Sorting"); | ||
14 | -//bookList.sort(sortBook); | ||
15 | -console.log(bookList); |
1 | - | ||
2 | -var alpha = ["a", "b", "c"]; | ||
3 | -var numeric = [1, 2, 3]; | ||
4 | -var alphaNumeric = alpha.concat(numeric); | ||
5 | -console.log("alphaNumeric : " + alphaNumeric ); | ||
6 | - | ||
7 | - | ||
8 | -var numbers = [1, 4, 9]; | ||
9 | -var element = numbers.pop(); | ||
10 | -console.log("element is : " + element ); | ||
11 | - | ||
12 | -var numbers = new Array(1, 4, 9); | ||
13 | -var length = numbers.push(10); | ||
14 | -console.log("new numbers is : " + numbers ); | ||
15 | - | ||
16 | -var arr = [0, 1, 2, 3].reverse(); | ||
17 | -console.log("Reversed array is : " + arr ); | ||
18 | - | ||
19 | -console.log("Reversed Again : " + arr.reverse()); | ||
20 | - | ||
21 | - | ||
22 | -var element = [105, 1, 2, 3].shift(); | ||
23 | -console.log ("Removed element is : " + element ); | ||
24 | - | ||
25 | - | ||
26 | -var arr = new Array("orange", "mango", "banana", "sugar"); | ||
27 | -var length = arr.unshift("water"); | ||
28 | -console.log("Returned array is : " + arr ); | ||
29 | -console.log("Length of the array is : " + length ); | ||
30 | - |
1 | -function addPrice(amount) { | ||
2 | - this.price = amount; | ||
3 | -} | ||
4 | -function book(title, author) { | ||
5 | - this.title = title; | ||
6 | - this.author = author; | ||
7 | - this.addPrice = addPrice; | ||
8 | -} | ||
9 | -var myBook = new book("Perl", "Mohtashim"); | ||
10 | -myBook.addPrice(100); | ||
11 | -console.log("Book title is : " + myBook.title); | ||
12 | -console.log("Book author is : " + myBook.author); | ||
13 | -console.log("Book price is : " + myBook.price); |
1 | -var val = new String("test"); | ||
2 | - | ||
3 | -console.log(val.charAt(1)); | ||
4 | -console.log(val.charCodeAt(1)); | ||
5 | -console.log(val.concat("aaa")); | ||
6 | -console.log(val.indexOf("st")); | ||
7 | -console.log(val.indexOf("t")); | ||
8 | -console.log(val.lastIndexOf("t")); | ||
9 | -console.log(val.replace("te","a")); | ||
10 | -console.log(val.slice(2)); | ||
11 | -console.log(val.split("es")); | ||
12 | -console.log(val.substr(2,2)); |
File mode changed
1 | -var events = require('events'); | ||
2 | -var eventEmitter = new events.EventEmitter(); | ||
3 | -var connectHandler = function connected() { | ||
4 | - console.log('connection successful.'); | ||
5 | - eventEmitter.emit('data_received'); | ||
6 | -} | ||
7 | - | ||
8 | -eventEmitter.on('connection', connectHandler); | ||
9 | - | ||
10 | -eventEmitter.on('data_received', function(){ | ||
11 | - console.log('data received successfully.'); | ||
12 | -}); | ||
13 | - | ||
14 | -eventEmitter.emit('connection'); | ||
15 | -console.log("Program Ended."); |
1 | -var events = require('events'); | ||
2 | -var eventEmitter = new events.EventEmitter(); | ||
3 | -var listner1 = function listner1() { | ||
4 | -console.log('listner1 executed.'); | ||
5 | -} | ||
6 | -var listner2 = function listner2() { | ||
7 | -console.log('listner2 executed.'); | ||
8 | -} | ||
9 | - | ||
10 | -eventEmitter.addListener('connection', listner1); | ||
11 | -eventEmitter.on('connection', listner2); | ||
12 | -var eventListeners = require('events').EventEmitter.listenerCount(eventEmitter,'connection'); | ||
13 | -console.log(eventListeners + " Listner(s) listening to connection event"); | ||
14 | - | ||
15 | -eventEmitter.emit('connection'); | ||
16 | -eventEmitter.removeListener('connection', listner1); | ||
17 | -console.log("Listner1 will not listen now."); | ||
18 | - | ||
19 | -eventEmitter.emit('connection'); | ||
20 | -eventListeners = require('events').EventEmitter.listenerCount(eventEmitter,'connection'); | ||
21 | -console.log(eventListeners + " Listner(s) listening to connection event"); | ||
22 | -console.log("Program Ended."); |
1 | -var express = require('express'); | ||
2 | -var app = express(); | ||
3 | -var bodyParser = require('body-parser'); | ||
4 | - | ||
5 | -app.use(bodyParser.urlencoded({ extended: false })); | ||
6 | -app.use(bodyParser.json()); | ||
7 | - | ||
8 | - | ||
9 | -var books = new Array(); | ||
10 | - | ||
11 | -app.get('/book/:bookId', function (req, res) { | ||
12 | - // Get book information | ||
13 | - | ||
14 | -}); | ||
15 | - | ||
16 | -app.put('/book/:bookId', function (req, res) { | ||
17 | - // Update book information | ||
18 | - | ||
19 | -}) | ||
20 | -app.post('/book', function (req, res) { | ||
21 | - // Create book information | ||
22 | -}) | ||
23 | - | ||
24 | -app.delete('/book/:bookId', function (req, res) { | ||
25 | - // Delete book information | ||
26 | - | ||
27 | -}) | ||
28 | -var server = app.listen(23023); | ||
29 | - console.log(books); |
1 | -{ | ||
2 | - "name": "assignment01", | ||
3 | - "version": "1.0.0", | ||
4 | - "description": "", | ||
5 | - "main": "index.js", | ||
6 | - "scripts": { | ||
7 | - "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | - }, | ||
9 | - "author": "", | ||
10 | - "license": "ISC", | ||
11 | - "dependencies": { | ||
12 | - "body-parser": "^1.17.1", | ||
13 | - "express": "^4.15.2" | ||
14 | - } | ||
15 | -} |
1 | -var express = require('express'); | ||
2 | -var app = express(); | ||
3 | -var bodyParser = require('body-parser'); | ||
4 | -var session = require('express-session') | ||
5 | - | ||
6 | -app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }})) | ||
7 | -app.use(bodyParser.urlencoded({ extended: false })); | ||
8 | -app.use(bodyParser.json()); | ||
9 | - | ||
10 | - | ||
11 | -var users = new Array(); | ||
12 | -var userId = 'test'; | ||
13 | -var userPass = '1234'; | ||
14 | - | ||
15 | -app.get('/login/:userId/password/:password', function (req, res) { | ||
16 | - if (req.params.userId == userId && req.params.password == userPass) { | ||
17 | - req.session.userId = userId; | ||
18 | - } | ||
19 | - res.send("Login"); | ||
20 | -}); | ||
21 | - | ||
22 | -app.get('/logout/:userId', function (req, res) { | ||
23 | - // Logout | ||
24 | - req.session.userId = null; | ||
25 | - res.send("LogOut"); | ||
26 | - | ||
27 | -}); | ||
28 | - | ||
29 | -var auth = function (req, res, next) { | ||
30 | - // Session Check | ||
31 | - if (req.session.userId != null) | ||
32 | - next(); | ||
33 | - else | ||
34 | - res.send("Error"); | ||
35 | - | ||
36 | -}; | ||
37 | -app.get('/user/:userId', auth,function (req, res) { | ||
38 | - // get User Information | ||
39 | - res.send("OK"); | ||
40 | -}); | ||
41 | -var server = app.listen(23023); |
1 | -{ | ||
2 | - "name": "assignment02", | ||
3 | - "version": "1.0.0", | ||
4 | - "description": "", | ||
5 | - "main": "index.js", | ||
6 | - "scripts": { | ||
7 | - "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | - }, | ||
9 | - "author": "", | ||
10 | - "license": "ISC", | ||
11 | - "dependencies": { | ||
12 | - "body-parser": "^1.17.1", | ||
13 | - "express": "^4.15.2", | ||
14 | - "express-session": "^1.15.2" | ||
15 | - } | ||
16 | -} |
1 | -var express = require('express'); | ||
2 | -var app = express(); | ||
3 | - | ||
4 | -app.get('/', function (req, res) { | ||
5 | - res.send('hello world'); | ||
6 | -}) | ||
7 | - | ||
8 | -app.route('/book') | ||
9 | - .get(function (req, res) { | ||
10 | - res.send('Get a random book'); | ||
11 | - }) | ||
12 | - .post(function (req, res) { | ||
13 | - res.send('Add a book'); | ||
14 | - }) | ||
15 | - .put(function (req, res) { | ||
16 | - res.send('Update the book'); | ||
17 | - }); | ||
18 | - | ||
19 | - | ||
20 | -var server = app.listen(23023); |
1 | -var express = require('express'); | ||
2 | -var app = express(); | ||
3 | -app.get('/', function (req, res) { | ||
4 | - res.send('Hello World'); | ||
5 | -}) | ||
6 | - | ||
7 | -var server = app.listen(23023, function () { | ||
8 | - var host = server.address().address | ||
9 | - var port = server.address().port | ||
10 | - console.log("Example app listening at http://%s:%s", host, port) | ||
11 | -}) | ||
12 | - |
1 | -var express = require('express'); | ||
2 | -var app = express(); | ||
3 | - | ||
4 | -app.get('/b', function (req, res, next) { | ||
5 | - console.log('the response will be sent by the next function ...') | ||
6 | - next() | ||
7 | -}, function (req, res) { | ||
8 | - res.send('Hello from B!') | ||
9 | -}) | ||
10 | - | ||
11 | -var cb0 = function (req, res, next) { | ||
12 | - console.log("call by cb0"); | ||
13 | - next() | ||
14 | -} | ||
15 | -var cb1 = function (req, res, next) { | ||
16 | - console.log("call by cb1"); | ||
17 | - res.send('Hello from C!') | ||
18 | -} | ||
19 | -app.get('/c', [cb0, cb1]) | ||
20 | - | ||
21 | -var server = app.listen(23023); |
1 | -{ | ||
2 | - "name": "render", | ||
3 | - "version": "1.0.0", | ||
4 | - "description": "", | ||
5 | - "main": "index.js", | ||
6 | - "scripts": { | ||
7 | - "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | - }, | ||
9 | - "author": "", | ||
10 | - "license": "ISC", | ||
11 | - "dependencies": { | ||
12 | - "ejs": "^2.5.6", | ||
13 | - "express": "^4.15.2" | ||
14 | - } | ||
15 | -} |
1 | -var express = require('express'); | ||
2 | -var app = express(); | ||
3 | - | ||
4 | -// The routing path matches requests to /about | ||
5 | -app.get('/about', function (req, res) { | ||
6 | - res.send('about') | ||
7 | -}) | ||
8 | - | ||
9 | -// The routing path matches requests to /random.text | ||
10 | -app.get('/random.text', function (req, res) { | ||
11 | - res.send('random.text') | ||
12 | -}) | ||
13 | - | ||
14 | -// This route path matches abcd, abxcd, abRANDOMcd, ab123cd, and so on. | ||
15 | -app.get('/ab*cd', function (req, res) { | ||
16 | - res.send('ab*cd') | ||
17 | -}) | ||
18 | - | ||
19 | -var server = app.listen(23023); |
1 | -var express = require('express'); | ||
2 | -var app = express(); | ||
3 | - | ||
4 | -var session = require('express-session') | ||
5 | - | ||
6 | -app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }})) | ||
7 | - | ||
8 | - | ||
9 | - | ||
10 | -app.get('/', function(req, res, next) { | ||
11 | - var sess = req.session; | ||
12 | - console.log(req.session); | ||
13 | - if (sess.views) { | ||
14 | - sess.views++; | ||
15 | - res.send("session Views " + sess.views); | ||
16 | - res.send(); | ||
17 | - } else { | ||
18 | - req.session.views = 1; | ||
19 | - res.send("welcome to the session demo. refresh!"); | ||
20 | - res.end(); | ||
21 | - } | ||
22 | -}); | ||
23 | - | ||
24 | -var server = app.listen(23023); |
1 | -{ | ||
2 | - "name": "session", | ||
3 | - "version": "1.0.0", | ||
4 | - "description": "", | ||
5 | - "main": "index.js", | ||
6 | - "scripts": { | ||
7 | - "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | - }, | ||
9 | - "author": "", | ||
10 | - "license": "ISC", | ||
11 | - "dependencies": { | ||
12 | - "express": "^4.15.2", | ||
13 | - "express-session": "^1.15.2" | ||
14 | - } | ||
15 | -} |
1 | -var express = require('express'); | ||
2 | -var app = express(); | ||
3 | - | ||
4 | -app.all('/', function (req, res, next) { | ||
5 | - console.log('Accessing the secret section ...') | ||
6 | - next() // pass control to the next handler | ||
7 | -}) | ||
8 | - | ||
9 | -app.get('/', function (req, res) { | ||
10 | - res.send('hello world'); | ||
11 | -}) | ||
12 | - | ||
13 | -app.post('/', function (req, res) { | ||
14 | - res.send('POST request to the homepage') | ||
15 | -}) | ||
16 | - | ||
17 | -var server = app.listen(23023); |
6.72 KB
1 | -US President Donald Trump said no nation should underestimate American resolve, as he arrived in Japan at the start of a marathon Asian tour. | ||
2 | -Addressing US troops at Yokota air base near Tokyo, he pledged to ensure the military had the resources needed to keep peace and defend freedom. | ||
3 | -Mr Trump's visit comes amid heightened tensions with North Korea over its nuclear programme and missile tests. | ||
4 | -It will be the longest tour of Asia by a US president in 25 years. | ||
5 | -"No-one, no dictator, no regime... should underestimate American resolve," President Trump told cheering US and Japanese troops shortly after his arrival in Japan. | ||
6 | -Before touching down, he told reporters on board Air Force One that he expected to meet Russian President Vladimir Putin during his trip. | ||
7 | -"I think it's expected we'll meet with Putin," he said. "We want Putin's help on North Korea." | ||
8 | -Mr Trump was meeting Japanese Prime Minister Shinzo Abe for lunch before the two leaders were due to play a round of golf. | ||
9 | -Stops in South Korea, China, Vietnam and the Philippines are also on the itinerary in the coming week. |
1 | -West Ham manager Slaven Bilic says he is under "big pressure" and in a "very difficult" situation after Saturday's 4-1 Premier League defeat by Liverpool. | ||
2 | - | ||
3 | -Thousands of Hammers supporters left London Stadium early for the second home game in a row as the Hammers were left a point above the bottom three. | ||
4 | - | ||
5 | -"The pressure mounts game by game and at this moment it is big," Bilic, 49, told BBC Sport. | ||
6 | - | ||
7 | -"We will see what the club will do. The club is above everyone." | ||
8 | - | ||
9 | -West Ham have lost three of their past four games at London Stadium and were unable to cope with Liverpool's pace on the counter-attack throughout Saturday's game. | ||
10 | - | ||
11 | -Mohamed Salah scored twice for the visitors, with Joel Matip and Alex Oxlade-Chamberlain also on target. Manuel Lanzini briefly gave West Ham home by making it 2-1. |
1 | -For less than a month’s rent in her hometown of Vancouver, Lydia Lee is having a second storey built onto the villa she rents on the tropical island of Bali. | ||
2 | -Relocating to Indonesia seven years ago has meant she’s been able to build her business and afford a much more lavish lifestyle than she could at home. A life coach, Lee can now eat out every day, employ a cleaner and get weekly massages. | ||
3 | -She ditched her six-figure salary in marketing and business development and now works for herself and travels the world. But relocating overseas doesn’t always work out so well financially. | ||
4 | -Financial shocks | ||
5 | -Not all expats find they can afford to live the high-life. InterNations, a networking resource for expats, recently surveyed more than 12,500 people living in 188 countries or territories and the picture the data paint of their finances is remarkably diverse. |
1 | -test |
1 | -TEST |
1 | -test07 |
1 | -TesT |
File mode changed
File mode changed
No preview for this file type
No preview for this file type
No preview for this file type
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
No preview for this file type
No preview for this file type
File mode changed
1 | -slfjslkfja;ldjkf |
1 | -const express = require('express'); | ||
2 | -const fileUpload = require('express-fileupload'); | ||
3 | -const app = express(); | ||
4 | - | ||
5 | -//var aws = require('aws-sdk'); | ||
6 | -//aws.config.loadFromPath('./awsconfig.json'); | ||
7 | - | ||
8 | -//var BUCKET_NAME = 'intothegalaxy'; | ||
9 | -//var s3 = new aws.S3(); | ||
10 | - | ||
11 | - | ||
12 | -function uploadFile(file, res) { | ||
13 | - | ||
14 | - // Use the mv() method to place the file somewhere on your server | ||
15 | - file.mv('./upload/' + file.name, function(err) { | ||
16 | - if (err) | ||
17 | - return res.status(500).send(err); | ||
18 | - | ||
19 | - res.send('File uploaded!'); | ||
20 | - }); | ||
21 | - | ||
22 | - | ||
23 | -} | ||
24 | - | ||
25 | -// default options | ||
26 | -app.use(fileUpload()); | ||
27 | - | ||
28 | -app.post('/', function(req, res) { | ||
29 | - if (!req.files) | ||
30 | - return res.status(400).send('No files were uploaded.'); | ||
31 | - uploadFile(req.files.file, res); | ||
32 | -}); | ||
33 | - | ||
34 | -app.get('/:fileName', function(req, res){ | ||
35 | - var file = __dirname + '/upload/' + req.params.fileName; | ||
36 | - res.download(file); // Set disposition and send it. | ||
37 | -}); | ||
38 | - | ||
39 | -var server = app.listen(23023); | ||
40 | - |
1 | -{ | ||
2 | - "name": "experiments11", | ||
3 | - "version": "1.0.0", | ||
4 | - "description": "", | ||
5 | - "main": "app.js", | ||
6 | - "scripts": { | ||
7 | - "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | - }, | ||
9 | - "repository": { | ||
10 | - "type": "git", | ||
11 | - "url": "git@khuhub.khu.ac.kr:Prof.JinSeongwook/OSS-2017-02.git" | ||
12 | - }, | ||
13 | - "author": "", | ||
14 | - "license": "ISC", | ||
15 | - "dependencies": { | ||
16 | - "aws-sdk": "^2.62.0", | ||
17 | - "express-fileupload": "^0.1.3" | ||
18 | - } | ||
19 | -} |
-
Please register or login to post a comment