This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a Websocket client (can be run in browser console) | |
// ref client https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications | |
// The standalone server can be found here https://gist.github.com/patrikbego/447c40f8eaee709d7a6a2d2cadbfd046 | |
const URL = 'ws://localhost:8000'; | |
let websocket; | |
function updateStatus(status) { | |
if (status === 'connected') { | |
console.log('All good'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.ByteArrayOutputStream; | |
import java.io.IOException; | |
import java.net.InetSocketAddress; | |
import java.nio.ByteBuffer; | |
import java.nio.channels.SelectionKey; | |
import java.nio.channels.Selector; | |
import java.nio.channels.ServerSocketChannel; | |
import java.nio.channels.SocketChannel; | |
import java.nio.charset.StandardCharsets; | |
import java.security.MessageDigest; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is native /pure /no-npm node.js file uploader. | |
* | |
* CLIENT FUNCTION: export function uploadFile(file) { | |
* fetch("http://localhost:8080/sys/upload", { | |
* method: 'POST', | |
* headers: { "Content-Type": "multipart/form-data;"}, | |
* body: file }).then(response => response.json() | |
* ).then( | |
* success => console.log(success) |