開始ページにフォーム処理を実装すると、システムでエラーが表示されます。
Express のコード
var http = require('http'),
express = require('express'),
app = express();
app.use(express.bodyParser());
// A route for the home page - and the page with a form
app.post('/', function(req, res) {
// Code for Handling the form
});
形:
<form action="/" method="post"> . . . </form>
今、私はこのエラーを受け取ります:
取得することはできません /
どうすればこの問題を解決できますか? いくつかのアイデア?
完全なルートの更新 - Jade を使用
// Set the view engine
app.set('view engine', 'jade');
// Where to find the view files
app.set('views', './views');
// A route for the home page - will render a view
app.post('/', function(req, res) {
res.render('index');
});
そしてここにフォームコード:
<form action="/" method="post">
<label>Name</label>
<input type="text" name="name">
<label>Text</label>
<textarea name="text" rows="10"></textarea>
<input type="submit">
</form>