A web application built with FastAPI (backend) and HTML + JavaScript (frontend) to assist with playing One Night Werewolf. The application can be launched with uvicorn.
one-night-werewolf-assistant/
├── backend/ # Backend Python package
│ ├── __init__.py # Package initialization
│ └── routes.py # API routes and endpoints
├── frontend/ # Frontend files
│ ├── index.html # Main HTML page
│ └── static/ # Static assets
│ ├── app.js # JavaScript application logic
│ └── style.css # CSS styles
├── main.py # Application entry point
├── requirements.txt # Python dependencies
└── README.md # This file
- Python 3.8 or higher
- pip (Python package installer)
- Clone the repository:
git clone https://github.com/lanchiang/one-night-werewolf-assistant.git
cd one-night-werewolf-assistant- Install dependencies:
pip install -r requirements.txtYou can launch the application using uvicorn in two ways:
Option 1: Using the main.py file directly
python main.pyOption 2: Using uvicorn command
uvicorn main:app --reloadThe application will start on http://localhost:8000
--reloadflag enables auto-reload on code changes (useful for development)- Use
--host 0.0.0.0to make the server accessible from other machines - Use
--port 8080to change the port (default is 8000)
Once running, you can access:
- Web Interface: http://localhost:8000
- API Documentation: http://localhost:8000/docs (Swagger UI)
- Alternative API Docs: http://localhost:8000/redoc (ReDoc)
- Health Check API: Monitor application status
- Application Info API: Get application details
- Interactive Web Interface: User-friendly HTML/JS frontend
- Responsive Design: Works on desktop and mobile devices
- RESTful API: Clean API structure with FastAPI
-
Backend (FastAPI):
main.py: Application initialization and configurationbackend/routes.py: API endpoint definitions- FastAPI automatically generates OpenAPI documentation
-
Frontend (HTML + JS):
index.html: Main HTML structureapp.js: Client-side JavaScript logicstyle.css: Styling and responsive design
- Open
backend/routes.py - Add new route functions:
@router.get("/api/your-endpoint")
async def your_function():
return {"message": "Your response"}- Edit
frontend/index.htmlfor structure changes - Edit
frontend/static/app.jsfor JavaScript functionality - Edit
frontend/static/style.cssfor styling updates
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Serve main HTML page |
| GET | /api/health |
Health check endpoint |
| GET | /api/info |
Get application information |
| GET | /docs |
Swagger UI documentation |
| GET | /redoc |
ReDoc documentation |
You can test the API endpoints using:
- Web Browser: Visit http://localhost:8000 and use the built-in buttons
- Swagger UI: Visit http://localhost:8000/docs for interactive API testing
- curl: Command line testing
curl http://localhost:8000/api/health
curl http://localhost:8000/api/info- fastapi: Modern web framework for building APIs
- uvicorn: ASGI server for running FastAPI applications
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.