내용으로 건너뛰기
wiki.akpil.net
사용자 도구
로그인
사이트 도구
검색
도구
문서 보기
이전 판
역링크
최근 바뀜
미디어 관리자
사이트맵
로그인
>
최근 바뀜
미디어 관리자
사이트맵
추적:
•
모르스_부호_변환기
모르스_부호_변환기
이 문서는 읽기 전용입니다. 원본을 볼 수는 있지만 바꿀 수는 없습니다. 문제가 있다고 생각하면 관리자에게 문의하세요.
===== 모르스 부호 변환기 ===== 자바스크립트, 파이썬, port 3040 으로 웹 접속 <code> # pip3 instasll flask jamo from flask import Flask, request, render_template_string from jamo import h2j, j2hcj app = Flask(__name__) MORSE_DICT = { 'ㄱ': '.-..', 'ㄴ': '..-.', 'ㄷ': '-...', 'ㄹ': '...-', 'ㅁ': '--', 'ㅂ': '.--.', 'ㅅ': '--.', 'ㅇ': '-.-', 'ㅈ': '.---', 'ㅊ': '-.-.', 'ㅋ': '-..-', 'ㅌ': '--..', 'ㅍ': '---.', 'ㅎ': '.---.', 'ㄺ' : '.-....-', 'ㄻ' : '.-..--', 'ㄼ' : '.-.....-', 'ㄿ' : '.-....-.', 'ㅀ' : '.-..--..', 'ㄽ' : '..--...', 'ㄲ': '.-...-..', 'ㄳ' : '--....', 'ㄵ' : '.---.', 'ㄶ' : '.--...--.', 'ㄸ' : '..--', 'ㅃ' : '..--..', 'ㅆ' : '......', 'ㅄ' : '---.--.-', 'ㅉ' : '..-...-.', 'ㅏ' : '.', 'ㅑ' : '..', 'ㅓ' : '-', 'ㅕ' : '...', 'ㅗ' : '.-', 'ㅛ' : '-.', 'ㅜ' : '....', 'ㅠ' : '.-.', 'ㅡ' : '-..', 'ㅣ' : '..-', 'ㅐ' : '.---', 'ㅔ' : '--..', 'ㅙ' : '.-..-', 'ㅝ' : '..--', 'ㅚ' : '--..', 'ㅒ' : '..--.-','ㅘ' : '.-.-.-', 'ㅖ' : '..--', 'ㅟ' : '----.-', 'ㅢ' : '...-.-..', 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-', 'Y': '-.--', 'Z': '--..', '1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....', '6': '-....', '7': '--...', '8': '---..', '9': '----.', '0': '-----', ' ': '/' } HTML_TEMPLATE = """ <!DOCTYPE html> <html> <head> <title>한글/영문/숫자 모르스 변환기 (Port 3040)</title> <style> body { font-family: 'Segoe UI', sans-serif; text-align: center; background-color: #eef2f3; margin-top: 50px; } .container { width: 60%; margin: auto; padding: 30px; background: white; border-radius: 15px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); } textarea { width: 95%; height: 120px; padding: 15px; font-size: 16px; border: 2px solid #ddd; border-radius: 10px; resize: none; margin-bottom: 15px; } button { background-color: #4CAF50; color: white; padding: 12px 30px; border: none; border-radius: 8px; font-size: 18px; cursor: pointer; transition: 0.3s; } button:hover { background-color: #45a049; } .box { text-align: left; margin-top: 25px; padding: 15px; border-radius: 8px; border-left: 5px solid #2196F3; background-color: #f9f9f9; } .morse-box { background: #2d2d2d; color: #ffeb3b; font-family: 'Courier New', monospace; word-break: break-all; font-size: 20px; letter-spacing: 2px; border-left: 5px solid #ff9800; min-height: 60px; } h4 { margin-bottom: 5px; color: #555; } </style> </head> <body> <div class="container"> <h1>📟 사운드 모르스 변환기</h1> <form method="POST"> <textarea name="text" placeholder="입력하세요...">{{ input_text }}</textarea><br> <button type="submit">변환 및 재생</button> </form> {% if result %} <div class="box"> <h4>📝 입력 데이터 :</h4> <div style="font-size: 18px;">{{ input_text }}</div> </div> <div class="box morse-box"> <h4>⚡ 모르스 부호 변환 결과 :</h4> <div id="typing-result"></div> </div> <script> const fullText = {{ result | tojson }}; const displayElement = document.getElementById('typing-result'); let index = 0; // Web Audio API 설정 const audioCtx = new (window.AudioContext || window.webkitAudioContext)(); function playBeep(isDash) { const oscillator = audioCtx.createOscillator(); const gainNode = audioCtx.createGain(); oscillator.connect(gainNode); gainNode.connect(audioCtx.destination); oscillator.type = 'sine'; oscillator.frequency.setValueAtTime(600, audioCtx.currentTime); // 주파수 600Hz const duration = isDash ? 0.2 : 0.07; // 대시(-)는 길게, 도트(.)는 짧게 gainNode.gain.setValueAtTime(0.1, audioCtx.currentTime); oscillator.start(); oscillator.stop(audioCtx.currentTime + duration); } function typeAndPlay() { if (index < fullText.length) { const char = fullText.charAt(index); displayElement.innerHTML += char; if (char === '.') { playBeep(false); } else if (char === '-') { playBeep(true); } index++; setTimeout(typeAndPlay, 100); // 0.1초 간격 } } window.onload = () => { if (fullText.length > 0) { typeAndPlay(); } }; </script> {% endif %} </div> </body> </html> """ @app.route('/', methods=['GET', 'POST']) def index(): result = "" input_text = "" if request.method == 'POST': input_text = request.form.get('text', '') processed = j2hcj(h2j(input_text.upper())) morse_list = [MORSE_DICT.get(char, char) for char in processed] result = " ".join(morse_list) return render_template_string(HTML_TEMPLATE, result=result, input_text=input_text) if __name__ == '__main__': app.run(host='0.0.0.0', port=3040, debug=False) </code> <code> 적당한 파일이름(여기서는 morse.py)으로 저장하고, python3 morse.py 로 실행 </code> ------------- 2026.03.18 akpil
모르스_부호_변환기.txt
· 마지막으로 수정됨:
2026/03/19 13:29
저자
akpil
문서 도구
문서 보기
이전 판
역링크
맨 위로