-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.py
26 lines (21 loc) · 857 Bytes
/
run.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
import argparse
from pathlib import Path
from stockfish_socket_server import app
def create_app(stockfish_path, debug_mode=False):
"""
Create the server Flask instance.
:param stockfish_path: Path to the stockfish binary
:param debug_mode: Boolean to enable Flask debug mode
:return: Flask app instance
"""
app.config['DEBUG'] = debug_mode
app.config['stockfish_path'] = stockfish_path
return app
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--stockfish-path', type=Path, required=True)
parser.add_argument('--debug-mode', type=bool, default=False)
args = parser.parse_args()
if not args.stockfish_path.exists():
raise ValueError(f'Stockfish executable not found at: {args.stockfish_path}')
create_app(args.stockfish_path, args.debug_mode).run()