Files
wordsearch/app.py
T
Mathew Sir Guest the bestandClaude Opus 4.6 9319f08875 feat: expand to 1014 words, add title-case display and 2 new themes
- Move word data from hardcoded seed.py to data/words.json
- Expand from 210 words across 7 categories to 1014 words across 14
  categories (animals, food, colors, sports, space, nature, music,
  science, countries, occupations, ocean, weather, mythology, technology)
- Word list sidebar now shows title case (Tiger) while grid stays
  uppercase; text input remains case-insensitive
- Add Ocean theme (light, blue accents) and Forest theme (dark, amber
  accents on deep green)
- Replace hardcoded rgba values with --coral-bg CSS variable so
  selection highlighting adapts per theme

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-07 02:43:43 -06:00

73 lines
2.2 KiB
Python

"""Tornado application entry point and route configuration."""
import os
import click
import tornado.ioloop
import tornado.web
from db import get_engine, get_session_factory, init_db
from handlers.main import MainHandler
from handlers.game import GameHandler
from handlers.howtoplay import HowToPlayHandler
from handlers.about import AboutHandler
from handlers.scoreboard import ScoreboardPageHandler
from handlers.api import (
CategoriesHandler,
NewGameHandler,
GameStateHandler,
GuessHandler,
ScoreboardAPIHandler,
)
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
def make_app(session_factory=None, debug=False):
"""Create and configure the Tornado application.
Args:
session_factory: SQLAlchemy session factory. If None, API
endpoints that require a database will not work.
debug: Enable debug mode (auto-reload, stack traces).
Returns:
A configured ``tornado.web.Application`` instance.
"""
return tornado.web.Application(
[
(r"/", MainHandler),
(r"/game", GameHandler),
(r"/howtoplay", HowToPlayHandler),
(r"/about", AboutHandler),
(r"/scoreboard", ScoreboardPageHandler),
(r"/api/categories", CategoriesHandler),
(r"/api/scoreboard", ScoreboardAPIHandler),
(r"/api/game/new", NewGameHandler),
(r"/api/game/([^/]+)", GameStateHandler),
(r"/api/game/([^/]+)/guess", GuessHandler),
],
template_path=os.path.join(BASE_DIR, "templates"),
static_path=os.path.join(BASE_DIR, "static"),
session_factory=session_factory,
debug=debug,
)
@click.command()
@click.option("--port", default=8888, type=int, help="Port to listen on.")
@click.option("--debug", is_flag=True, help="Enable debug mode.")
def main(port, debug):
"""Start the web server."""
engine = get_engine()
init_db(engine)
session_factory = get_session_factory(engine)
app = make_app(session_factory=session_factory, debug=debug)
app.listen(port)
print(f"Server started at http://localhost:{port}")
tornado.ioloop.IOLoop.current().start()
if __name__ == "__main__":
main()