I want to set up a bunch of raspberry pies that each run a webserver, and then allow people to simply go to a website on their laptop and get an overview of all of these raspberries on the network (and then of course they'll be able to do stuff with them by calling the web server).
Is it possible to set up the raspberry pies in such a way that they are discoverable on the local network from JavaScript? Without the need of a server? Or is this only possible from native apps?
Allow devices an access to your local network (Just Google OSX local network port, Raspberian network access)
Then use any discovery library that you want.
I'd suggest using something like Cote NodeJS (easly runs on raspbery and any device) - it discovers any other process running cote on local network automaticly;
You can also build your own discovery script or just configure in advance
You could install node.js on your raspberry pies and install socketio on your pies. Then you could simply interactive with them from the client side
Related
I got a problematic assignment from my employers.
I was given the task of developing simple software that will run strictly on Google Chrome,
without attempting to connect to the web (Security reasons).
I know flutter development and I feel comfortable with the sdk.
How should I develop a web app that can be deployed using a usb stick?
Looks like PWA can be an option, but the documentation is lacking in detail.
The system does not have the ability to run a local web server.
The Flutter app must be able to work with JS libraries, I intend to use jsQR.
service workers and indexedDB could help you for develop offline route app and offline api.
mdn docs for service workers
I'm not sure that this will fit your particular case: you say that the system can't run a local webserver, but what if you provide the webserver along with your software?
I just discovered get_server: you can find it here. It aims to allow developers to host their own HTTP server by using only flutter, without resorting to external tools or other coding/scripting languages. It allows also (and that's the relevant part) to wrap your flutter web app and make it run on local network.
For now I only tried with a very simple example, but it seems to be working. These are the steps I took:
create a new flutter project: since I needed the webserver to run on Windows, I had to get flutter ready for that (see here for help)
add get_server to the new pubspec.yaml
run flutter build web on your flutter web project, and copy the build/web output
folder in the root folder of the new project (I renamed the folder while copying since flutter might change the content of the web folder)
delete all the content of lib/main.dart
paste this (this the actual content of main.dart)
import 'package:get_server/get_server.dart' as gs;
void main() {
gs.runApp(
gs.GetServerApp(home: gs.FolderWidget('folderName')),
);
}
folderName is the name of the renamed folder containing the flutter web app build.
I ran this on Windows 'device' from AndroidStudio, and my original flutter web app was reachable at localhost:8080 (for now I just used the default options of get_server). I also got the webserver (empty) GUI as a white window: I guess that can be useful for some information regarding the server itself, although, if that windows closes, localhost:8080 becomes unavailable.
But, once released, you should be able to just run the executable from the USB stick, and then connect to it with Chrome.
PS: after some time using GetServer, I had to switch to other packages because of not-so-good docs and support. Now I'm using shelf, but also Alfred is a notable mention.
If I have a Node.js app running on a machine on the LAN that runs a web server (Fastify) and it is configured to be accessible to all devices on the LAN, how could I use JavaScript in the browser on another machine to detect that server on the LAN?
Example: On a NAS connected to my router, I run a Docker container that creates a HTTP API at the address 192.168.1.28:3000. I can manually type this into any browser on the LAN and it will access the Docker container. How can I use JavaScript to detect the existence of this server without knowing its address?
You can't.
While there are protocols for announcing the presence of a service on a network, none are supported by JS running in a webpage.
Browser extensions (such as Bonjour Browser and the poorly reviewed Railduino Zeroconf-Lookup) are possible, but since you didn't mention writing a browser extension I'll assume they aren't an option.
There's things like WebRTC but unless your device advertises that you're out of luck.
This is by design.
Can you imagine if an arbitrary web page could scan your local network and report back to some arbitrary server what it discovers?
This question is about the basic feasibility of this project but you are welcome to recommend ideas on how it could be done. I would like to create a hosted Java web application that creates a Server in the local network of the device.
For example: You can go to example.com in your Browser and start the application that creates a server in the local network of the device (Windows-PC). Other devices (Android) can connect to the server (UDP) with an installed Android-App.
Is this concept possible? I am afraid browser security renders this level of access impossible..
As others have pointed out it is not possible.
I will instead choose a local Java application that has to be installed.
In our web application, we using a Java applet to invoke MS.Word application by jacob jar e.g. Word to open, edit, and when it saves automatically it uploaded to the server.
Google Chrome will no longer support NPAPI, so soon we can not run our applet in Chrome anymore.
So, any suggestions for an alternative for the Java applet. We want to make the same experience for the user, just like before.
We have the same problem. With Webstart is not longer possible to do that communication. We are going to use Websockets between webstart application and browser. Our first attempt is to start a websockets server in the webstart and make browser connect to localhosts. If this is not possible for security limitations in the browsers then we are going to do it through the webserver, browser and webstart application connecting to the webserver and exchanging messages.
I can see 2 distinct possibilities.
Create a standalone application that "wraps" your web application using a technology such as electron. You can then do your browser to desktop integration as you like. This will require an install on the client.
Launch a webstart application (or it could really be any installation that happens on the client). It will need to start a webserver, or connect to a webserver and communicate via http.
I'm saddened by the loss of the Applet. It is a technology not easily replaced. And another methods seem somewhat like 'workarounds'. There is no easy, cross-browser way to break out of the browser sandbox and access the system.
For myself, the loss of the Applet has simply meant that automating some of these processes has become too difficult and it is just better to find an alternative way of achieving a similar end result.
A small note: If you are starting a local webserver, be mindful of security. It can be accessed by other processes on the system. Wouldn't it be fun to open word on anyone's system by sending a request to a port!
I want to write an Extension for the google chrome browser which reads some links from a website and copy these links into a file. I want to send this file via ssh to another computer in my local network.
How can I setup and use a ssh connection in my chrome extension?
Assuming you mean scp, not ssh, here are your options:
Set up a WebSocket proxy. Write JavaScript to send the XHR-fetched ArrayBuffer. WebSockets can go over SSL, so you'll probably be satisfied with that rather than implementing SSH in JavaScript (and then scp over that).
Same idea but an HTTP proxy. This would be pretty painful. See Web-based SSH for overview.
Write a Chrome App, thereby getting access to chrome.sockets. Implement SSH in JavaScript. See paramikojs to get started.
Chrome App, Native Client. This can actually work; see Secure Shell. Add scp functionality.
The Chrome-App-based solutions raise a separate question of how to get the web content. You might be able to use Chrome Apps webview. Or you can message the content between the app and a Chrome Extension.
There are probably other approaches as well. But you get the idea: you have a lot of coding ahead of you.