简体   繁体   English

是否可以使用node.js在同一目录中对多个玉文件进行app.post一次?

[英]Is it possible to app.post once for multiple jade file in the same directory using node.js?

I am trying to use node.js to create a program that stores a task, each task is dynamic: such as adding two random number, so I store the task as a jade file, since the second time you called, the random number might be different 我正在尝试使用node.js创建一个存储任务的程序,每个任务都是动态的:例如添加两个随机数,所以我将该任务存储为玉文件,因为您第二次调用该随机数,与众不同

The problem I am having right now is that I can write the app.post for each task, but I don't want to do that as there might be ten jade files in that directory, and I have to write app.post for each task ten times, which is not scalable, so I was wondering if there is a way to run all the jade file using one app.post? 我现在遇到的问题是我可以为每个任务编写app.post,但我不想这样做,因为该目录中可能有十个玉文件,因此我必须为每个任务编写app.post任务十次,这是不可扩展的,所以我想知道是否有一种方法可以使用一个app.post运行所有jade文件?

Any hint would be appreciated 任何提示将不胜感激

Use app.get('/:task', do) for routing and req.params.task to get the value passed from client. 使用app.get('/:task', do)进行路由,并使用req.params.task获取从客户端传递的值。

See http://expressjs.com/api.html#req.params for more information. 有关更多信息,请参见http://expressjs.com/api.html#req.params

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM