Skip to content
Snippets Groups Projects
Commit 5408a63a authored by Nils G.'s avatar Nils G.
Browse files

Added in-browser protocol debug tool

parent 2dc3142d
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# try something like
def index(): return dict(message="hello from debug.py")
\ No newline at end of file
{{extend 'layout.html'}}
<h1>
JSON debug
</h1>
<table>
<tr>
<td>
<u>You</u><br>
<form>
URL: <input type="text" name="url" id="url" value="{{=URL('room','create')}}"><br>
<textarea rows=20 cols=60 id="input" placeholder="Your JSON parameters"></textarea><br>
<input type="submit">
</form>
</td>
<td style="vertical-align: top">
<u>Server</u><br>
Status-Code<input type="text" id="status" readonly=""><br>
<textarea readonly="" rows=20 cols=60 id="server" placeholder="Server Response"></textarea><br>
</td>
</tr>
</table>
<script type="text/javascript">
$('form').submit(function(){
$.ajax({
type: 'POST',
url: $("#url").val(),
dataType: 'json',
data: $('#input').val(),
contentType : 'application/json',
success: function(data) {
$("#status").val("200");
$("#server").val(JSON.stringify(data, null, 4));
},
error: function(xhr, statusText, errorThrown){
$("#status").val(xhr.status);
$("#server").val(errorThrown);
}
});
return (false);
});
</script>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="{{=URL('static','js/jquery.js')}}" type="text/javascript"></script>
</head>
<body>
{{include}}
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment