Node.js - 将表单数据发送到hapi

时间:2016-03-15 08:05:28

标签: html node.js hapijs

我正在尝试将一个变量从html格式发送到hapi,但我认为我做错了。

addword.html:

    <form id="messages" action="/addword" method="POST">
  Your variable:
  <br>
  <input  type="text" name="your_variable" value="your_value">
  <br>
  <input type="submit" value="Submit">
</form>

server.coffee

server.route
    method: 'GET'
    path: '/addword'
    handler: (request, reply) ->
        reply.file './public/addword.html'  

###
ADD WORD
###

server.route 
  method: 'POST'
  path: '/addword'
  config: payload: output: 'data'
  handler: (request, response) ->
    your_variable = request.payload.your_variable
    console.log your_variable
    return

/server.js

/public/addword.html

我应该改变什么才能使它发挥作用?

0 个答案:

没有答案