xxxxxxxxxx
<html>
<head>
<title>Flask/Gevent WebSocket Test</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('form').submit(function(event){
ws.send($('#data').val())
return false;
});
if ("WebSocket" in window) {
ws = new WebSocket("ws://" + document.domain + ":5000/api");
ws.onmessage = function (msg) {
$("#log").append("<p>"+msg.data+"</p>")
};
} else {
alert("WebSocket not supported");
}
});
</script>
</head>
<body>
<h1>Send:</h1>
<form method='POST' action='#'>
<textarea name='data' id="data"></textarea>
<div><input type='submit'></div>
</form>
<h1>Receive:</h1>
<div id="log"></div>
</body>
</html>
Modified http://code.jquery.com/jquery-1.4.2.min.js to a secure url
https://code.jquery.com/jquery-1.4.2.min.js