This is the backend component of the SubEdit web application. It consists of:
- A Python-based
SubEditclass for subtitle manipulation - FastAPI endpoints for serving the API
- Uvicorn server for ASGI hosting
Set up a virtual environment:
cd subedit/backend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txtCreate a .env file in the subedit/backend directory with the following variables:
# Set to 0 to run in production
DEBUG=1
# Defaults to http://localhost:5173 when DEBUG=1
FRONTEND_URL=https://your.frontend.domain
# Defaults to ../user_files when DEBUG=1
USER_FILES_PATH=/path/to/your/upload/directory
# Defaults to ../logs when DEBUG=1
LOG_PATH=/path/to/your/logs/directory
# Defaults to main_log.log when DEBUG=1
LOG_FILE=filename.log
# Defaults to 30 when DEBUG=1
LOG_AGE=30
Ensure the directory specified in USER_FILES_PATH exists and is writable.
Start the Uvicorn server:
uvicorn main:app --reloadCheck if the server is running correctly:
curl -X GET http://127.0.0.1:8000/pingExpected response:
{"status": "ok", "debug": true}Subtitle translation using Duck.ai is only available in local environments due to a dependency on stpyv8, which is not supported on most remote servers.
If you want to enable subtitle translation with Duck.ai:
- Ensure that stpyv8 can be compiled and installed in your local Python environment (Linux/Mac recommended).
- Uncomment corresponding lines at the end of
requirements.txtand runpip install -r requirements.txtagain. - By default AI translation is available only in debug mode. If you want to run in production make
DEBUG=0in.envand removeif DEBUGconditions inmain.pyandsubedit.py.
Feel free to submit issues or pull requests.
MIT License