initial commit blyad
This commit is contained in:
99
templates/index.html
Normal file
99
templates/index.html
Normal file
@@ -0,0 +1,99 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Quick Problem Platform</title>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
<style>
|
||||
.leaderboard-table {
|
||||
width: auto;
|
||||
min-width: 400px;
|
||||
max-width: 600px;
|
||||
border-collapse: collapse;
|
||||
margin: 2em 0;
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 8px #0001;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.leaderboard-table th, .leaderboard-table td {
|
||||
padding: 0.7em 1em;
|
||||
text-align: center;
|
||||
}
|
||||
.leaderboard-table th {
|
||||
background: #f5f5f5;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
.leaderboard-table tr:nth-child(even) {
|
||||
background: #fafbfc;
|
||||
}
|
||||
.leaderboard-table tr:nth-child(odd) {
|
||||
background: #f0f2f5;
|
||||
}
|
||||
.leaderboard-table td {
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
font-size: 1em;
|
||||
}
|
||||
.leaderboard-table tr:hover {
|
||||
background: #e0e7ff;
|
||||
}
|
||||
.problems-list {
|
||||
max-width: 600px;
|
||||
min-width: 400px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.problems-list ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.problems-list li {
|
||||
padding: 0.5em 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Quick Problem Platform</h1>
|
||||
<!--<a href="/problem/new">Submit New Problem</a>-->
|
||||
<section class="problems-list">
|
||||
<h2>Problems</h2>
|
||||
<ul>
|
||||
{% for problem in problems %}
|
||||
<li><a href="/problem/{{ problem.id }}">{{ problem.title }}</a></li>
|
||||
{% else %}
|
||||
<li>No problems yet.</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Leaderboard</h2>
|
||||
<table class="leaderboard-table">
|
||||
<tr>
|
||||
<th>Rank</th>
|
||||
<th>User</th>
|
||||
<th>Problem</th>
|
||||
<th>Runtime (s)</th>
|
||||
<th>Memory (KB)</th>
|
||||
<th>Line Number</th>
|
||||
<th>Timestamp</th>
|
||||
</tr>
|
||||
{% for entry in leaderboard %}
|
||||
<tr>
|
||||
<td>{{ loop.index }}</td>
|
||||
<td>{{ entry[0] }}</td>
|
||||
<td>{{ problem_titles.get(entry[1], 'Unknown') }}</td>
|
||||
<td>{{ '%.4f'|format(entry[2]) }}</td>
|
||||
<td>{{ entry[3] }}</td>
|
||||
<td>{{ entry[4] if entry[4] else '-' }}</td>
|
||||
<td>{{ entry[5] }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td colspan="7">No leaderboard entries yet.</td></tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
72
templates/problem.html
Normal file
72
templates/problem.html
Normal file
@@ -0,0 +1,72 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ problem.title }}</title>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
<link href="https://fonts.cdnfonts.com/css/jetbrains-mono" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="problem-header">
|
||||
<button class="back-btn" onclick="window.location.href='/'">← Back</button>
|
||||
<h1 style="margin-bottom:0;">{{ problem.title }}</h1>
|
||||
</div>
|
||||
<div class="problem-desc">{{ problem.description }}</div>
|
||||
<div class="editor-section" style="max-width:1160;margin:0">
|
||||
<h2 style="margin-top:0;">Submit Your Solution (Python)</h2>
|
||||
<form method="post">
|
||||
<label for="username">Username (optional):</label>
|
||||
<input type="text" name="username" id="username" placeholder="Anonymous" style="margin-bottom:10px;">
|
||||
<div id="editor"></div>
|
||||
<textarea name="user_code" id="user_code" style="display:none;"></textarea>
|
||||
<div class="editor-actions">
|
||||
<button type="submit">Run & Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/monaco-editor@0.45.0/min/vs/loader.js"></script>
|
||||
<script>
|
||||
require.config({ paths: { 'vs': 'https://cdn.jsdelivr.net/npm/monaco-editor@0.45.0/min/vs' } });
|
||||
require(['vs/editor/editor.main'], function() {
|
||||
var editor = monaco.editor.create(document.getElementById('editor'), {
|
||||
value: '',
|
||||
language: 'python',
|
||||
theme: 'vs-light',
|
||||
fontFamily: 'JetBrains Mono, monospace',
|
||||
fontLigatures: true,
|
||||
automaticLayout: true,
|
||||
fontSize: 16,
|
||||
minimap: { enabled: false }
|
||||
});
|
||||
document.querySelector('form').addEventListener('submit', function(e) {
|
||||
var code = editor.getValue();
|
||||
if (!code.trim()) {
|
||||
alert('Please enter your code before submitting.');
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
document.getElementById('user_code').value = code;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% if result %}
|
||||
<div class="editor-section" style="max-width:1160;margin:0;margin-top: 5px;">
|
||||
<h3>Result:</h3>
|
||||
<b>Runtime:</b> {{ '%.4f'|format(result.runtime) }} seconds<br>
|
||||
<b>Output:</b>
|
||||
<pre>{{ result.output }}</pre>
|
||||
{% if result.error %}
|
||||
<b>Error:</b>
|
||||
<pre style="color:red;">{{ result.error }}</pre>
|
||||
{% endif %}
|
||||
{% if result.passed %}
|
||||
<p style="color:green;">Passed!</p>
|
||||
{% else %}
|
||||
<p style="color:red;">Failed!</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<!--<a href="/">Back to Problems</a>-->
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user