나는 익스프레스를 배우려고 노력하고있다. 내 HTML 페이지를로드하는 데 FS를 사용하고 있습니다. Google 검색을 통해 Express에서 대신 ASP.NET을 사용하고 있다는 것을 알 수있었습니다.Express 전용 메인 페이지 로딩
Server.js :
var express = require('express');
var path = require('path');
var fs = require('fs');
var app = express();
app.use(require('body-parser').urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname+'/')))
app.get('/', function(a,b,c){
fs.readFileSync('index.html');
});
app.post('/testaction', function(a,b){
console.log(a.body.log);
fs.readFileSync('Logged.html');
});
app.listen(3000);
index.html을 : 당신이 FS를 사용하지 않아도 파일을 제공하기 위해
<!DOCTYPE html>
<html>
<head>
<title>Test Page</title>
</head>
<body>
<form method="post" action="http://localhost:3000/testaction">
<h1>Log This:</h1>
<input type="text" name="log"/>
<input type="submit", value="Press Me!"/>
</form>
</body>
</html>