Upload folder using huggingface_hub
Browse files- app.py +0 -27
- templates/index.html +0 -27
app.py
CHANGED
|
@@ -74,33 +74,6 @@ async def save_pgn(req: PGNRequest):
|
|
| 74 |
f.write(req.pgn)
|
| 75 |
return {"status": "ok", "file": filename}
|
| 76 |
|
| 77 |
-
class MatchmakingRequest(BaseModel):
|
| 78 |
-
enable: bool
|
| 79 |
-
|
| 80 |
-
@app.post("/api/matchmaking")
|
| 81 |
-
async def toggle_matchmaking(req: MatchmakingRequest):
|
| 82 |
-
config_path = os.path.join(os.path.dirname(__file__), "lichess-bot", "config.yml")
|
| 83 |
-
if os.path.exists(config_path):
|
| 84 |
-
with open(config_path, "r") as f:
|
| 85 |
-
config = yaml.safe_load(f)
|
| 86 |
-
|
| 87 |
-
config["matchmaking"]["allow_matchmaking"] = req.enable
|
| 88 |
-
config["matchmaking"]["challenge_timeout"] = 1 if req.enable else 30
|
| 89 |
-
|
| 90 |
-
with open(config_path, "w") as f:
|
| 91 |
-
yaml.dump(config, f, default_flow_style=False)
|
| 92 |
-
|
| 93 |
-
# Schedule reboot
|
| 94 |
-
async def reboot():
|
| 95 |
-
await asyncio.sleep(1)
|
| 96 |
-
# pkill will kill start_bot.py, causing start.sh to exit and HF to cleanly restart the Space!
|
| 97 |
-
os.system("pkill -f start_bot.py")
|
| 98 |
-
|
| 99 |
-
asyncio.create_task(reboot())
|
| 100 |
-
return {"status": "ok", "message": "Applying config and rebooting..."}
|
| 101 |
-
|
| 102 |
-
return JSONResponse(status_code=500, content={"error": "Config not found"})
|
| 103 |
-
|
| 104 |
@app.get("/")
|
| 105 |
async def index(request: Request):
|
| 106 |
return templates.TemplateResponse(request=request, name="index.html")
|
|
|
|
| 74 |
f.write(req.pgn)
|
| 75 |
return {"status": "ok", "file": filename}
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
@app.get("/")
|
| 78 |
async def index(request: Request):
|
| 79 |
return templates.TemplateResponse(request=request, name="index.html")
|
templates/index.html
CHANGED
|
@@ -157,7 +157,6 @@
|
|
| 157 |
<option value="veloct">Black: VeloCT Ultimate</option>
|
| 158 |
</select>
|
| 159 |
<button class="btn-reset" onclick="resetGame()">Restart Game</button>
|
| 160 |
-
<button class="btn-reset" id="btnMatchmaking" onclick="toggleMatchmaking()" style="background: #ff5e7e; box-shadow: 0 0 10px #ff5e7e;">⚔️ Battle Bots (OFF)</button>
|
| 161 |
</div>
|
| 162 |
|
| 163 |
<script>
|
|
@@ -166,32 +165,6 @@
|
|
| 166 |
var $status = $('#status');
|
| 167 |
var history_moves = ["<bos>"];
|
| 168 |
var progressInterval;
|
| 169 |
-
var matchmakingEnabled = false;
|
| 170 |
-
|
| 171 |
-
function toggleMatchmaking() {
|
| 172 |
-
matchmakingEnabled = !matchmakingEnabled;
|
| 173 |
-
var btn = $('#btnMatchmaking');
|
| 174 |
-
|
| 175 |
-
if(matchmakingEnabled) {
|
| 176 |
-
btn.html("⚔️ Battle Bots (ON)");
|
| 177 |
-
btn.css("background", "#00ff88").css("box-shadow", "0 0 10px #00ff88");
|
| 178 |
-
} else {
|
| 179 |
-
btn.html("⚔️ Battle Bots (OFF)");
|
| 180 |
-
btn.css("background", "#ff5e7e").css("box-shadow", "0 0 10px #ff5e7e");
|
| 181 |
-
}
|
| 182 |
-
|
| 183 |
-
$status.html("<b>Applying settings and Rebooting Server... Please wait ~10 seconds.</b>");
|
| 184 |
-
|
| 185 |
-
$.ajax({
|
| 186 |
-
url: '/api/matchmaking',
|
| 187 |
-
type: 'POST',
|
| 188 |
-
contentType: 'application/json',
|
| 189 |
-
data: JSON.stringify({ enable: matchmakingEnabled }),
|
| 190 |
-
success: function(res) {
|
| 191 |
-
// Server will reboot!
|
| 192 |
-
}
|
| 193 |
-
});
|
| 194 |
-
}
|
| 195 |
|
| 196 |
var whitePlayer = "human";
|
| 197 |
var blackPlayer = "neural";
|
|
|
|
| 157 |
<option value="veloct">Black: VeloCT Ultimate</option>
|
| 158 |
</select>
|
| 159 |
<button class="btn-reset" onclick="resetGame()">Restart Game</button>
|
|
|
|
| 160 |
</div>
|
| 161 |
|
| 162 |
<script>
|
|
|
|
| 165 |
var $status = $('#status');
|
| 166 |
var history_moves = ["<bos>"];
|
| 167 |
var progressInterval;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
var whitePlayer = "human";
|
| 170 |
var blackPlayer = "neural";
|