如何使用node.js应用程序从客户端获取数据

发布于 2025-02-02 08:10:26 字数 743 浏览 1 评论 0原文

我已经使用p5.js库在JavaScript中写了一个游戏。现在,我想在服务器上托管游戏,以对像亚马逊土耳其人这样的服务进行调查。理想情况下,客户在游戏中或在node.js或服务器上存储游戏中的游戏时会收到一个URL并玩游戏,并在完成播放后将其导出为.CSV文件。完成游戏后,CSV。文件应自动发送到我可以访问的位置。我在服务器托管或类似主题方面的经验为零。

因此,出现了几个问题:

  1. 像Heroku这样的托管服务适合举办游戏吗?
  2. 我需要使用node.js做到这一点吗?
  3. 这两个中的哪一个会提取数据并将其存储到CSV上?文件存储在哪里?
  4. 我如何获得或访问CSV。后?
  5. 解决问题的其他选择吗?

预先感谢!

i have written a game in javascript with the p5.js library. Now i want to host the game on a server to conduct a survey on a service like amazon turk. Ideally the clients recieve a URL to the game and play it while in-game actions are tracked and stored in node.js or on the server and exported as a .csv file once they are done playing. After they finish the game the csv. file should be sent automatically to a location that i can then access. I have zero experience in server hosting or similar topics.

So a couple questions arise:

  1. Is a hosting service like Heroku suitable for hosting the game?
  2. Do i need to use node.js to make this happen?
  3. Which of those two would extract the data and store it to a csv? And where is the file stored?
  4. How do i get or access the csv. after?
  5. Any alternative takes to solve the problem?

Thanks alot in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的痛♀有谁懂 2025-02-09 08:10:27

如果我是你,我会像以下那样做:

主机
由于您的项目基本上是HTML& JavaScript静态内容,
aws s3的静态托管如果您只想托管它,则Git Hub页面是另一个选择)。

也可以使用webpack服务在Node.js环境上托管,但需要其他工作。 (但是,如果您需要其他NPM软件包来生成.CSV文件,则无论如何您都需要WebPack来包装JS文件并将其连接到HTML)

数据存储
两种方式很大,
首先是将其存储在文件系统上。通过应用程序中的JS脚本生成.csv,然后将其保存在托管应用程序的位置(如果您使用S3,则可以访问它,但是我不确定它是否可以通过脚本编写对象),

第二个是发布数据到另一个API端点。 (例如,在触发lambda的AWS上构建API网关(将其存储在S3上)

这只是一个示例,我不知道您要实现什么,而是考虑到它。祝你好运。酷游戏顺便说一句。

If I were you, I would do it like below:

Host
Since your project is basically a html & JavaScript static contents,
AWS S3's static hosting would be sufficient (Also, the current git hub pages is another option if you just want to host it).

Hosting on node.js environment is also available using webpack serving, but it requires additional works. (but if you require other npm packages to generate .csv file, you need webpack anyway to bundle js file and attach it to html)

Data Storing
Two ways are considerable,
the first is to store it on the filesystem. Generate .csv via JS script within your app, and save it where the app is hosted (if you go with s3, you can access it afterwards, but I'm not sure if it can write objects by script)

The second is to post the data to another API endpoint. (for example building an API Gateway on AWS that triggers Lambda, which stores it on S3)

It's merely an example and I don't know exactly what you want to achieve, but take it into considerations. Good luck. Cool game BTW.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文