-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpaas.py
executable file
·72 lines (56 loc) · 1.81 KB
/
paas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/python2
import config
import header
import cgi,commands,os,MySQLdb
header.header_content()
print """
<form action="/paas.py" id="form" method="POST">
<div>
<label for="language">Select language:</label>
<select class="select" id="language">
<option value="1">C</option>
<option value="2">php</option>
<option value="3">python 2.7</option>
<option value="4">python 3</option>
</select>
</div>
<div class="form-group">
<textarea class ="form-control" id="code" rows="10" cols="50" style="width:auto;display: block;margin-left: auto;margin-right: auto;"></textarea>
</div>
<div class="form-group">
Input:
<textarea class ="form-control" id="input" rows="5" cols="50" style="width:auto;display: block;margin-left: auto;margin-right: auto;"></textarea>
</div>
<button type="submit">Run</button>
</form>
<iframe id='output'></iframe>
<script src="/js/jquery.min.js"></script>
<script>
$("#form").submit( function(){
var code = $('textarea#code').val();
var input = $('textarea#input').val();
var language = $('#language').val();
$.ajax({
type: 'POST',
url: '/code_execute.py',
data: { 'code' : code, 'language': language, 'input': input },
dataType: 'json',
success: function(d) {
$('#output').contents().find('html').html("<pre> "+ d.output + " </pre>");
},
error: function() {
$('#output').contents().find('html').html("<h4>Empty File</h4>")
}
});
return false;
});
</script>
"""
print """
<script src="/bootstrap/js/bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.15/js/dataTables.bootstrap.min.js"></script>
<script src="/js/script.min.js"></script>
</body>
</html>
"""