A sleek, dark-themed Morse code encoder built with Django. Type text and see instant Morse output, then play it back with smooth WebAudio tones. Clean UI, responsive layout, and snappy UX.
- β¨ Features
- πΌοΈ Screenshots
- π οΈ Technologies Used
- π Project Structure
- ποΈ Architecture Overview
- π Installation & Setup
- π» Usage
- π§ Configuration
- π¦ Dependencies
- π API Documentation
- π€ Contributing
- π₯ Contributors
- π License
- π Useful Resources
- π§ͺ Testing
- π’ Deployment
- π©Ί Troubleshooting
- β FAQ
- Live Encoding: Debounced, real-time conversion as you type
- Standards-based Mapping: Letters, numbers, and common punctuation
- Copy to Clipboard: Quick copy of Morse output
- WebAudio Tones: Pure oscillator-based dit/dah playback
- Natural Timing: ITU-style unit timing for letters/words
- No Audio Files: Lightweight, fast, and consistent
- Dark Theme: Custom gradients, subtle shadows, accessible contrast
- Responsive Layout: Optimized for mobile and desktop
- Bootstrap 5: Familiar, ergonomic components
- Django 4.2 - Python web framework
- Python 3.10+ - Language runtime
- SQLite - Default local database
- HTML5, CSS3, JavaScript
- Bootstrap 5 and Bootstrap Icons
- WebAudio API for tone generation
- Git and pip
morseCoder/
βββ src/
β βββ main/ # Django project
β β βββ settings.py # Settings (static dirs, templates)
β β βββ urls.py # Root URL config
β β βββ wsgi.py # WSGI
β β βββ asgi.py # ASGI
β βββ core/ # App: views, urls, morse logic
β β βββ morse.py # Morse code mapping
β β βββ views.py # home & API view
β β βββ urls.py # app urls
β β βββ templates/ # app templates (loaded via DIRS)
β βββ templates/ # Project templates
β β βββ base.html # Base layout
β β βββ home.html # Home page
β β βββ components/ # Partials (navbar)
β βββ static/ # Static assets
β β βββ css/dark.css # Dark theme styles
β β βββ js/audio.js # WebAudio player
β βββ manage.py # Django CLI entry
βββ README.md # This file
βββ LICENSE # MIT
- Django MVC:
urls.pyroutes βviews.pyrender templates or return JSON. - Templates:
base.htmlwraps pages;home.htmlimplements the UI; partials live intemplates/components/. - Static assets: Custom dark theme CSS in
static/css/dark.cssand WebAudio logic instatic/js/audio.js. - Morse mapping:
core/morse.pycontains the symbol mapping; viewtext_translateencodes server-side. - Frontend behavior:
home.htmluses Fetch API for live updates and delegates audio towindow.morseAudio.
Data flow: user input β fetch /text_translate/ β JSON response β output textarea β optional audio playback.
- Python 3.10 or higher
- pip
- Git
-
Clone the repository
git clone https://github.com/Huerte/morseCoder.git cd morseCoder -
Create and activate a virtual environment
python -m venv venv # Windows venv\Scripts\activate # macOS/Linux # source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Run database migrations
cd src python manage.py migrate -
Run the development server
python manage.py runserver
-
Access the app
- App:
http://127.0.0.1:8000 - Admin:
http://127.0.0.1:8000/admin
- App:
Note: For production, set
DEBUG=Falseand configureALLOWED_HOSTS.
- Open the home page
- Type any text in the left panel
- See Morse code appear in the right panel
- Click Play to listen; click Copy to copy output
Key settings in src/main/settings.py:
TEMPLATES = [
{
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
}
]
STATIC_URL = '/static/'
STATICFILES_DIRS = [BASE_DIR / 'static']For deployment, add STATIC_ROOT and run collectstatic.
Python runtime dependencies (representative):
- Django 4.2.x
Dev tools (optional but recommended):
- black, isort, flake8, mypy, pytest, pytest-django
Add a requirements.txt and pin versions for reproducible builds.
- Endpoint:
GET /text_translate/ - Query:
text(string) - Response: JSON
Request:
GET /text_translate/?text=HELLO%20WORLDResponse:
{
"encoded_code": ".... . .-.. .-.. --- / .-- --- .-. .-.. -.."
}Notes:
- Unsupported characters are skipped
- Words are separated by
/in the output
Contributions are welcome!
- Fork the repo:
https://github.com/Huerte/morseCoder - Create a feature branch:
git checkout -b feature/amazing - Commit changes:
git commit -m "feat: add amazing" - Push branch:
git push origin feature/amazing - Open a Pull Request
Guidelines:
- Follow existing code style
- Keep UI accessible (contrast, focus states)
- Prefer small, focused PRs
!HuerteDev Backend Developer |
|
| Want to see your avatar here? Check the Contributing section and open a PR. | |
We welcome contributions from the community!
This project is licensed under the MIT License - see the LICENSE file for details.
cd src
pytest -qcore: unit tests forMORSE_CODEcoverage and encoding edge casesviews: response shape and error paths for/text_translate/templates: smoke render forhome.html
- Set environment variables (
DJANGO_SECRET_KEY,DJANGO_ALLOWED_HOSTS, etc.). - Configure static files:
STATIC_ROOT = BASE_DIR / 'staticfiles'
- Collect static assets:
python manage.py collectstatic --noinput
- Run with a production server (example):
gunicorn main.wsgi:application --bind 0.0.0.0:8000
- Put Gunicorn behind Nginx or your platformβs router.
For simple platforms (e.g., Render/Heroku), see their Django deployment guides.
-
Static files not loading
- Ensure
STATICFILES_DIRSis correct locally; setSTATIC_ROOTin production. - Run
collectstaticand verify your server servesSTATIC_ROOT.
- Ensure
-
400 Bad Request in production
- Add your domain/IP to
ALLOWED_HOSTS.
- Add your domain/IP to
-
No audio playback
- Some browsers block autoplay; click Play after interaction.
- Check console for
AudioContexterrors.
-
Why encode on the server instead of the client?
- Keeps logic centralized and testable; clients remain thin.
-
Can I add Morse β Text decoding?
- Yes. Add a reverse mapping and a new endpoint or client-side parser.
-
How do I change tone frequency or timing?
- Edit constants in
static/js/audio.js(FREQ,DIT_MS).
- Edit constants in
morseCoder on GitHub: https://github.com/Huerte/morseCoder
.png)
.png)