英文:
Getting data from a backend server side file and displaying it on a client side html site
问题
我有一个 AWS 服务器,持续在后台运行一个程序来更新一个 txt 文件。我想要使用最新的文件数据进行计算,并在一个 HTML 页面上显示它。
(我还将使用 systemctl 在服务器上托管 HTML)
我尝试使用 fs,但似乎无法访问,因为它是客户端侧的,我也尝试搜索我所处的情况,但找不到相关信息。
(注意:这是我第一次尝试这样的操作,并且使用服务器,所以不确定我可以/不能做什么)
英文:
I have an AWS server that continually runs a program on the background updating a txt file. I want to make calculations with the latest file data and display it on an html page.
(I will also be using systemctl to host the html on the server)
I tried using fs but it's just not possible to access since it's a client side I think, I also tried searching for the situation I'm in but just can't find anything on it.
(Note: First time trying something like this and using a server so not sure what I can/can't do)
答案1
得分: 1
I think AJAX can help you, fetch function to be more specific.
I suggest following solution.
If this script works on your server, you can make an asynchronous function in JavaScript that will fetch data from the server once in a while and then, using JS, update the table on the frontend.
Or, as It was suggested in comments - use WebSockets with its JavaScript API.
英文:
I think AJAX can help you, fetch function to be more specific
I suggest following solution
If this script works on your server you can make asynchronous function in javascript, that will fetch data from server once in a while and then using JS update table on frontend
Or, as It was suggested in comments - use WebSockets with its JavaScript API
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论