-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBACKUP-practice.html
More file actions
156 lines (135 loc) · 3.49 KB
/
BACKUP-practice.html
File metadata and controls
156 lines (135 loc) · 3.49 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Codeship Practice Environment</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f0f8ff;
color: #0a0a0a;
margin: 0;
padding: 20px;
}
header {
background-color: #9fd3ec;
color: white;
padding: 25px;
text-align: center;
border-radius: 12px;
margin-bottom: 20px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
h1 {
margin: 0;
}
.container {
max-width: 900px;
margin: auto;
}
label {
font-weight: bold;
}
select, textarea, button {
width: 100%;
border-radius: 8px;
padding: 10px;
margin-top: 10px;
font-size: 16px;
}
textarea {
background-color: #161b22;
color: #9fd3ec;
border: 1px solid #9fd3ec;
min-height: 200px;
resize: vertical;
}
button {
background-color: #9fd3ec;
color: #fff;
border: none;
font-weight: bold;
cursor: pointer;
margin-top: 15px;
}
button:hover {
background-color: #7ac1d9;
}
pre {
background-color: #161b22;
color: #9fd3ec;
padding: 15px;
border-radius: 8px;
margin-top: 15px;
min-height: 100px;
white-space: pre-wrap;
}
.nav {
text-align: center;
margin-top: 20px;
}
.nav a {
background-color: #9fd3ec;
color: #fff;
padding: 12px 25px;
text-decoration: none;
font-weight: bold;
border-radius: 8px;
transition: background 0.3s;
}
.nav a:hover {
background-color: #7ac1d9;
}
</style>
</head>
<body>
<header>
<h1>Codeship Practice Environment</h1>
<p>Write and run code in multiple languages!</p>
</header>
<div class="container">
<label for="language">Choose a language:</label>
<select id="language">
<option value="71">Python 3</option>
<option value="63">C++</option>
<option value="62">Java</option>
<option value="50">C</option>
<option value="54">JavaScript (Node.js)</option>
</select>
<label for="code">Write your code here:</label>
<textarea id="code">// Example: print("Hello, Codeship!")</textarea>
<button onclick="runCode()">Run Code</button>
<h3>Output:</h3>
<pre id="output">Your output will appear here...</pre>
<div class="nav">
<a href="index.html">← Back to Chatbot</a>
</div>
</div>
<script>
async function runCode() {
const code = document.getElementById("code").value;
const language = document.getElementById("language").value;
const output = document.getElementById("output");
output.innerText = "Running...";
try {
const response = await fetch('https://judge0-ce.p.rapidapi.com/submissions?base64_encoded=false&wait=true', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-RapidAPI-Key': 'YOUR_RAPIDAPI_KEY', // Replace with your key
'X-RapidAPI-Host': 'judge0-ce.p.rapidapi.com'
},
body: JSON.stringify({
language_id: language,
source_code: code
})
});
const result = await response.json();
output.innerText = result.stdout || result.compile_output || result.stderr || "No output";
} catch (err) {
output.innerText = "Error: " + err;
}
}
</script>
</body>
</html>