Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	
		buletomato25
		
	commited on
		
		
					Commit 
							
							·
						
						86d99b4
	
1
								Parent(s):
							
							1afd5a5
								
ログイン機能搭載
Browse files- __pycache__/app.cpython-311.pyc +0 -0
- __pycache__/database.cpython-311.pyc +0 -0
- __pycache__/users.cpython-311.pyc +0 -0
- app.py +85 -8
- database.py +3 -0
- init/createdatabase.sql +14 -0
- instance/site.db +0 -0
- requirements.txt +4 -0
- templates/login.html +131 -1
- templates/new_person.html +130 -1
- templates/resetting_password.html +54 -0
- users.py +17 -0
    	
        __pycache__/app.cpython-311.pyc
    ADDED
    
    | Binary file (13.8 kB). View file | 
|  | 
    	
        __pycache__/database.cpython-311.pyc
    ADDED
    
    | Binary file (275 Bytes). View file | 
|  | 
    	
        __pycache__/users.cpython-311.pyc
    ADDED
    
    | Binary file (1.17 kB). View file | 
|  | 
    	
        app.py
    CHANGED
    
    | @@ -1,16 +1,22 @@ | |
| 1 | 
            -
            from flask import Flask, request, jsonify, render_template, send_from_directory
         | 
| 2 | 
             
            import base64
         | 
| 3 | 
             
            import os
         | 
| 4 | 
             
            import shutil
         | 
| 5 | 
             
            import numpy as np
         | 
| 6 | 
             
            import string
         | 
| 7 | 
             
            import random
         | 
| 8 | 
            -
            from datetime import datetime
         | 
| 9 | 
             
            from pyannote.audio import Model, Inference
         | 
| 10 | 
             
            from pydub import AudioSegment
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 11 |  | 
| 12 | 
             
            # Hugging Face のトークン取得(環境変数 HF に設定)
         | 
| 13 | 
            -
            hf_token = os.environ.get("HF")
         | 
|  | |
| 14 | 
             
            if hf_token is None:
         | 
| 15 | 
             
                raise ValueError("HUGGINGFACE_HUB_TOKEN が設定されていません。")
         | 
| 16 |  | 
| @@ -22,6 +28,25 @@ os.makedirs(cache_dir, exist_ok=True) | |
| 22 | 
             
            model = Model.from_pretrained("pyannote/embedding", use_auth_token=hf_token, cache_dir=cache_dir)
         | 
| 23 | 
             
            inference = Inference(model)
         | 
| 24 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 25 | 
             
            def cosine_similarity(vec1, vec2):
         | 
| 26 | 
             
                vec1 = vec1 / np.linalg.norm(vec1)
         | 
| 27 | 
             
                vec2 = vec2 / np.linalg.norm(vec2)
         | 
| @@ -79,23 +104,75 @@ def generate_filename(random_length): | |
| 79 | 
             
                filename = f"{current_time}_{random_string}.wav"
         | 
| 80 | 
             
                return filename
         | 
| 81 |  | 
| 82 | 
            -
             | 
| 83 |  | 
| 84 | 
             
            # トップページ(テンプレート: index.html)
         | 
| 85 | 
             
            @app.route('/')
         | 
| 86 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 87 | 
             
            def index():
         | 
| 88 | 
            -
                 | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 89 |  | 
| 90 | 
             
            # フィードバック画面(テンプレート: feedback.html)
         | 
| 91 | 
             
            @app.route('/feedback', methods=['GET', 'POST'])
         | 
| 92 | 
             
            def feedback():
         | 
| 93 | 
            -
                 | 
|  | |
| 94 |  | 
| 95 | 
             
            # 会話詳細画面(テンプレート: talkDetail.html)
         | 
| 96 | 
             
            @app.route('/talk_detail', methods=['GET', 'POST'])
         | 
| 97 | 
             
            def talk_detail():
         | 
| 98 | 
            -
                 | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 99 |  | 
| 100 | 
             
            # 音声アップロード&解析エンドポイント
         | 
| 101 | 
             
            @app.route('/upload_audio', methods=['POST'])
         | 
|  | |
| 1 | 
            +
            from flask import Flask, request, jsonify, render_template, send_from_directory,redirect, make_response, Response, session
         | 
| 2 | 
             
            import base64
         | 
| 3 | 
             
            import os
         | 
| 4 | 
             
            import shutil
         | 
| 5 | 
             
            import numpy as np
         | 
| 6 | 
             
            import string
         | 
| 7 | 
             
            import random
         | 
| 8 | 
            +
            from datetime import datetime, timedelta
         | 
| 9 | 
             
            from pyannote.audio import Model, Inference
         | 
| 10 | 
             
            from pydub import AudioSegment
         | 
| 11 | 
            +
            from flask_sqlalchemy import SQLAlchemy
         | 
| 12 | 
            +
            from flask_login import LoginManager, UserMixin, login_user, logout_user, login_required
         | 
| 13 | 
            +
            from database import db 
         | 
| 14 | 
            +
            from users import Users
         | 
| 15 | 
            +
            from werkzeug.security import generate_password_hash, check_password_hash
         | 
| 16 |  | 
| 17 | 
             
            # Hugging Face のトークン取得(環境変数 HF に設定)
         | 
| 18 | 
            +
            #hf_token = os.environ.get("HF")
         | 
| 19 | 
            +
            hf_token = "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"
         | 
| 20 | 
             
            if hf_token is None:
         | 
| 21 | 
             
                raise ValueError("HUGGINGFACE_HUB_TOKEN が設定されていません。")
         | 
| 22 |  | 
|  | |
| 28 | 
             
            model = Model.from_pretrained("pyannote/embedding", use_auth_token=hf_token, cache_dir=cache_dir)
         | 
| 29 | 
             
            inference = Inference(model)
         | 
| 30 |  | 
| 31 | 
            +
            app = Flask(__name__)
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            app.config['SECRET_KEY'] = os.urandom(24)
         | 
| 34 | 
            +
            # データベース設定
         | 
| 35 | 
            +
            app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'
         | 
| 36 | 
            +
            app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            # db を Flask アプリに紐づける
         | 
| 39 | 
            +
            db.init_app(app)
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            # Flask-Login の設定
         | 
| 42 | 
            +
            login_manager = LoginManager()
         | 
| 43 | 
            +
            login_manager.init_app(app)
         | 
| 44 | 
            +
            login_manager.login_view = "login"
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            @login_manager.user_loader
         | 
| 47 | 
            +
            def load_user(user_id):
         | 
| 48 | 
            +
                return Users.query.get(int(user_id))
         | 
| 49 | 
            +
             | 
| 50 | 
             
            def cosine_similarity(vec1, vec2):
         | 
| 51 | 
             
                vec1 = vec1 / np.linalg.norm(vec1)
         | 
| 52 | 
             
                vec2 = vec2 / np.linalg.norm(vec2)
         | 
|  | |
| 104 | 
             
                filename = f"{current_time}_{random_string}.wav"
         | 
| 105 | 
             
                return filename
         | 
| 106 |  | 
| 107 | 
            +
             | 
| 108 |  | 
| 109 | 
             
            # トップページ(テンプレート: index.html)
         | 
| 110 | 
             
            @app.route('/')
         | 
| 111 | 
            +
            def top():
         | 
| 112 | 
            +
                return redirect('/login')
         | 
| 113 | 
            +
             | 
| 114 | 
            +
            # ログイン後画面
         | 
| 115 | 
            +
            @app.route('/after')
         | 
| 116 | 
            +
            @login_required # ログインしているユーザのみアクセス許可
         | 
| 117 | 
             
            def index():
         | 
| 118 | 
            +
                users = Users.query.order_by(Users.id).all()
         | 
| 119 | 
            +
                return render_template('index.html', users=users)
         | 
| 120 | 
            +
             | 
| 121 | 
            +
            @app.route('/index', methods=['GET', 'POST'])
         | 
| 122 | 
            +
            def index_page():
         | 
| 123 | 
            +
                users = Users.query.order_by(Users.id).all()
         | 
| 124 | 
            +
                return render_template('index.html', users=users)
         | 
| 125 |  | 
| 126 | 
             
            # フィードバック画面(テンプレート: feedback.html)
         | 
| 127 | 
             
            @app.route('/feedback', methods=['GET', 'POST'])
         | 
| 128 | 
             
            def feedback():
         | 
| 129 | 
            +
                users = Users.query.order_by(Users.id).all()
         | 
| 130 | 
            +
                return render_template('feedback.html', users=users)
         | 
| 131 |  | 
| 132 | 
             
            # 会話詳細画面(テンプレート: talkDetail.html)
         | 
| 133 | 
             
            @app.route('/talk_detail', methods=['GET', 'POST'])
         | 
| 134 | 
             
            def talk_detail():
         | 
| 135 | 
            +
                users = Users.query.order_by(Users.id).all()
         | 
| 136 | 
            +
                return render_template('talkDetail.html', users=users)
         | 
| 137 | 
            +
             | 
| 138 | 
            +
            # ログイン画面(テンプレート: login.html)
         | 
| 139 | 
            +
            @app.route('/login', methods=['GET', 'POST'])
         | 
| 140 | 
            +
            def login():
         | 
| 141 | 
            +
               if request.method == "POST":
         | 
| 142 | 
            +
                    username = request.form.get('username')
         | 
| 143 | 
            +
                    password = request.form.get('password')
         | 
| 144 | 
            +
                    # Userテーブルからusernameに一致するユーザを取得
         | 
| 145 | 
            +
                    user = Users.query.filter_by(username=username).first()
         | 
| 146 | 
            +
                    if check_password_hash(user.password, password):
         | 
| 147 | 
            +
                        login_user(user)
         | 
| 148 | 
            +
                        return redirect('after')
         | 
| 149 | 
            +
                    else:
         | 
| 150 | 
            +
                        # 入力したユーザー名のパスワードが間違っている場合
         | 
| 151 | 
            +
                        # return "<p>パスワードが間違っています。</p>"
         | 
| 152 | 
            +
                        return Response(status=404, response="ページが見つかりません。")
         | 
| 153 | 
            +
               else:
         | 
| 154 | 
            +
                    return render_template('login.html')
         | 
| 155 | 
            +
             | 
| 156 | 
            +
            # 登録画面(テンプレート: new_person.html)
         | 
| 157 | 
            +
            @app.route('/new_person', methods=['GET', 'POST'])
         | 
| 158 | 
            +
            def new_person():
         | 
| 159 | 
            +
                if request.method == "POST":
         | 
| 160 | 
            +
                    username = request.form.get('username')
         | 
| 161 | 
            +
                    password = request.form.get('password')
         | 
| 162 | 
            +
                    # Userのインスタンスを作成
         | 
| 163 | 
            +
                    user = Users(username=username, password=generate_password_hash(password, method='sha256'), email=username)
         | 
| 164 | 
            +
                    db.session.add(user)
         | 
| 165 | 
            +
                    db.session.commit()
         | 
| 166 | 
            +
                    return redirect('login')
         | 
| 167 | 
            +
                else:
         | 
| 168 | 
            +
                    return render_template('new_person.html')
         | 
| 169 | 
            +
             | 
| 170 | 
            +
            @app.before_request
         | 
| 171 | 
            +
            def before_request():
         | 
| 172 | 
            +
                # リクエストのたびにセッションの寿命を更新する
         | 
| 173 | 
            +
                session.permanent = True
         | 
| 174 | 
            +
                app.permanent_session_lifetime = timedelta(minutes=15)
         | 
| 175 | 
            +
                session.modified = True
         | 
| 176 |  | 
| 177 | 
             
            # 音声アップロード&解析エンドポイント
         | 
| 178 | 
             
            @app.route('/upload_audio', methods=['POST'])
         | 
    	
        database.py
    ADDED
    
    | @@ -0,0 +1,3 @@ | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            from flask_sqlalchemy import SQLAlchemy
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            db = SQLAlchemy()
         | 
    	
        init/createdatabase.sql
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            USE app;
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            CREATE TABLE users(
         | 
| 4 | 
            +
                user_id INT PRIMARY KEY AUTO_INCREMENT,
         | 
| 5 | 
            +
                username VARCHAR(255),
         | 
| 6 | 
            +
                password VARCHAR(255),
         | 
| 7 | 
            +
                
         | 
| 8 | 
            +
            );
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            INSERT INTO users(username,password) VALUES('sample','sample');
         | 
| 11 | 
            +
            INSERT INTO users(username,password) VALUES('test','test');
         | 
| 12 | 
            +
            INSERT INTO users(username,password) VALUES('app','app');
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            GRANT ALL ON app.* TO test;
         | 
    	
        instance/site.db
    ADDED
    
    | 
            File without changes
         | 
    	
        requirements.txt
    CHANGED
    
    | @@ -3,3 +3,7 @@ pyannote.audio==2.1.1 | |
| 3 | 
             
            numpy==1.23.5
         | 
| 4 | 
             
            pydub==0.25.1
         | 
| 5 | 
             
            matplotlib==3.6.3
         | 
|  | |
|  | |
|  | |
|  | 
|  | |
| 3 | 
             
            numpy==1.23.5
         | 
| 4 | 
             
            pydub==0.25.1
         | 
| 5 | 
             
            matplotlib==3.6.3
         | 
| 6 | 
            +
            uwsgi
         | 
| 7 | 
            +
            flask-sqlalchemy
         | 
| 8 | 
            +
            PyMySQL
         | 
| 9 | 
            +
            flask-login
         | 
    	
        templates/login.html
    CHANGED
    
    | @@ -4,7 +4,137 @@ | |
| 4 | 
             
                <meta charset="UTF-8" />
         | 
| 5 | 
             
                <meta name="viewport" content="width=device-width, initial-scale=1.0" />
         | 
| 6 | 
             
                <title>ログイン画面</title>
         | 
| 7 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 8 |  | 
| 9 | 
             
              </head>
         | 
| 10 | 
             
              <body>
         | 
|  | |
| 4 | 
             
                <meta charset="UTF-8" />
         | 
| 5 | 
             
                <meta name="viewport" content="width=device-width, initial-scale=1.0" />
         | 
| 6 | 
             
                <title>ログイン画面</title>
         | 
| 7 | 
            +
               <style>
         | 
| 8 | 
            +
                @charset "UTF-8";
         | 
| 9 | 
            +
            body {
         | 
| 10 | 
            +
              font-family: Arial, sans-serif;
         | 
| 11 | 
            +
              padding: 20px;
         | 
| 12 | 
            +
              background-color: #f4f4f4;
         | 
| 13 | 
            +
              height: 100vh;
         | 
| 14 | 
            +
              display: flex;
         | 
| 15 | 
            +
              justify-content: center;
         | 
| 16 | 
            +
              align-items: center;
         | 
| 17 | 
            +
            }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            h2 {
         | 
| 20 | 
            +
              margin-bottom: 20px;
         | 
| 21 | 
            +
              text-align: center;
         | 
| 22 | 
            +
            }
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            a {
         | 
| 25 | 
            +
              text-decoration: none;
         | 
| 26 | 
            +
              color: #000000cc;
         | 
| 27 | 
            +
            }
         | 
| 28 | 
            +
            a:hover {
         | 
| 29 | 
            +
              text-decoration: underline;
         | 
| 30 | 
            +
            }
         | 
| 31 | 
            +
            .container {
         | 
| 32 | 
            +
              max-width: 800px;
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              background-color: #fff;
         | 
| 35 | 
            +
              padding: 20px 80px;
         | 
| 36 | 
            +
              border-radius: 8px;
         | 
| 37 | 
            +
              box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
         | 
| 38 | 
            +
            }
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            #transcription {
         | 
| 41 | 
            +
              white-space: pre-wrap;
         | 
| 42 | 
            +
              padding: 10px;
         | 
| 43 | 
            +
              background-color: #e9e9e9;
         | 
| 44 | 
            +
              border-radius: 4px;
         | 
| 45 | 
            +
              margin-bottom: 20px;
         | 
| 46 | 
            +
              max-height: 400px;
         | 
| 47 | 
            +
              overflow-y: auto;
         | 
| 48 | 
            +
            }
         | 
| 49 | 
            +
            button {
         | 
| 50 | 
            +
              margin: 5px;
         | 
| 51 | 
            +
              padding: 10px 10px;
         | 
| 52 | 
            +
              border: none;
         | 
| 53 | 
            +
              border-radius: 4px;
         | 
| 54 | 
            +
              background-color: #007bff;
         | 
| 55 | 
            +
              color: #fff;
         | 
| 56 | 
            +
              cursor: pointer;
         | 
| 57 | 
            +
            }
         | 
| 58 | 
            +
            .history-button {
         | 
| 59 | 
            +
              margin-top: 20px;
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              padding: 10px 20px;
         | 
| 62 | 
            +
              background-color: #007bff;
         | 
| 63 | 
            +
              color: white;
         | 
| 64 | 
            +
              border: none;
         | 
| 65 | 
            +
              border-radius: 5px;
         | 
| 66 | 
            +
              cursor: pointer;
         | 
| 67 | 
            +
            }
         | 
| 68 | 
            +
            history-button:hover {
         | 
| 69 | 
            +
              background-color: #0056b3;
         | 
| 70 | 
            +
            }
         | 
| 71 | 
            +
             | 
| 72 | 
            +
            .flex {
         | 
| 73 | 
            +
              display: flex;
         | 
| 74 | 
            +
              justify-content: center;
         | 
| 75 | 
            +
            }
         | 
| 76 | 
            +
            .new-person {
         | 
| 77 | 
            +
              text-align: center;
         | 
| 78 | 
            +
            }
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            .controls {
         | 
| 81 | 
            +
              display: flex;
         | 
| 82 | 
            +
              flex-direction: column;
         | 
| 83 | 
            +
              align-items: center;
         | 
| 84 | 
            +
            }
         | 
| 85 | 
            +
            .record-button {
         | 
| 86 | 
            +
              width: 80px;
         | 
| 87 | 
            +
              height: 80px;
         | 
| 88 | 
            +
              background-color: transparent;
         | 
| 89 | 
            +
              border-radius: 50%;
         | 
| 90 | 
            +
             | 
| 91 | 
            +
              display: flex;
         | 
| 92 | 
            +
              justify-content: center;
         | 
| 93 | 
            +
              align-items: center;
         | 
| 94 | 
            +
              cursor: pointer;
         | 
| 95 | 
            +
              box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
         | 
| 96 | 
            +
              transition: all 0.2s ease;
         | 
| 97 | 
            +
            }
         | 
| 98 | 
            +
             | 
| 99 | 
            +
            .record-icon {
         | 
| 100 | 
            +
              width: 60px;
         | 
| 101 | 
            +
              height: 60px;
         | 
| 102 | 
            +
              background-color: #d32f2f;
         | 
| 103 | 
            +
              border-radius: 50%;
         | 
| 104 | 
            +
              transition: all 0.2s ease;
         | 
| 105 | 
            +
            }
         | 
| 106 | 
            +
             | 
| 107 | 
            +
            .recording .record-icon {
         | 
| 108 | 
            +
              width: 40px;
         | 
| 109 | 
            +
              height: 40px;
         | 
| 110 | 
            +
              border-radius: 10%;
         | 
| 111 | 
            +
            }
         | 
| 112 | 
            +
             | 
| 113 | 
            +
            .record-p {
         | 
| 114 | 
            +
              border: 2px dashed #0000008c;
         | 
| 115 | 
            +
            }
         | 
| 116 | 
            +
             | 
| 117 | 
            +
            .disabled {
         | 
| 118 | 
            +
              background-color: gray;
         | 
| 119 | 
            +
              cursor: not-allowed;
         | 
| 120 | 
            +
            }
         | 
| 121 | 
            +
             | 
| 122 | 
            +
            .record-icon.recording {
         | 
| 123 | 
            +
              width: 40px;
         | 
| 124 | 
            +
              height: 40px;
         | 
| 125 | 
            +
              border-radius: 0;
         | 
| 126 | 
            +
            }
         | 
| 127 | 
            +
             | 
| 128 | 
            +
            .new-person-right-container {
         | 
| 129 | 
            +
              padding-left: 20px;
         | 
| 130 | 
            +
            }
         | 
| 131 | 
            +
             | 
| 132 | 
            +
            .record-container {
         | 
| 133 | 
            +
              display: flex;
         | 
| 134 | 
            +
              justify-content: center;
         | 
| 135 | 
            +
            }
         | 
| 136 | 
            +
             | 
| 137 | 
            +
               </style>
         | 
| 138 |  | 
| 139 | 
             
              </head>
         | 
| 140 | 
             
              <body>
         | 
    	
        templates/new_person.html
    CHANGED
    
    | @@ -3,7 +3,136 @@ | |
| 3 | 
             
              <head>
         | 
| 4 | 
             
                <meta charset="UTF-8" />
         | 
| 5 | 
             
                <meta name="viewport" content="width=device-width, initial-scale=1.0" />
         | 
| 6 | 
            -
                < | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 7 | 
             
                <title>ユーザー登録画面</title>
         | 
| 8 | 
             
              </head>
         | 
| 9 | 
             
              <body>
         | 
|  | |
| 3 | 
             
              <head>
         | 
| 4 | 
             
                <meta charset="UTF-8" />
         | 
| 5 | 
             
                <meta name="viewport" content="width=device-width, initial-scale=1.0" />
         | 
| 6 | 
            +
                <style>
         | 
| 7 | 
            +
                  @charset "UTF-8";
         | 
| 8 | 
            +
                  body {
         | 
| 9 | 
            +
                    font-family: Arial, sans-serif;
         | 
| 10 | 
            +
                    padding: 20px;
         | 
| 11 | 
            +
                    background-color: #f4f4f4;
         | 
| 12 | 
            +
                    height: 100vh;
         | 
| 13 | 
            +
                    display: flex;
         | 
| 14 | 
            +
                    justify-content: center;
         | 
| 15 | 
            +
                    align-items: center;
         | 
| 16 | 
            +
                  }
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  h2 {
         | 
| 19 | 
            +
                    margin-bottom: 20px;
         | 
| 20 | 
            +
                    text-align: center;
         | 
| 21 | 
            +
                  }
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  a {
         | 
| 24 | 
            +
                    text-decoration: none;
         | 
| 25 | 
            +
                    color: #000000cc;
         | 
| 26 | 
            +
                  }
         | 
| 27 | 
            +
                  a:hover {
         | 
| 28 | 
            +
                    text-decoration: underline;
         | 
| 29 | 
            +
                  }
         | 
| 30 | 
            +
                  .container {
         | 
| 31 | 
            +
                    max-width: 800px;
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    background-color: #fff;
         | 
| 34 | 
            +
                    padding: 20px 80px;
         | 
| 35 | 
            +
                    border-radius: 8px;
         | 
| 36 | 
            +
                    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
         | 
| 37 | 
            +
                  }
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  #transcription {
         | 
| 40 | 
            +
                    white-space: pre-wrap;
         | 
| 41 | 
            +
                    padding: 10px;
         | 
| 42 | 
            +
                    background-color: #e9e9e9;
         | 
| 43 | 
            +
                    border-radius: 4px;
         | 
| 44 | 
            +
                    margin-bottom: 20px;
         | 
| 45 | 
            +
                    max-height: 400px;
         | 
| 46 | 
            +
                    overflow-y: auto;
         | 
| 47 | 
            +
                  }
         | 
| 48 | 
            +
                  button {
         | 
| 49 | 
            +
                    margin: 5px;
         | 
| 50 | 
            +
                    padding: 10px 10px;
         | 
| 51 | 
            +
                    border: none;
         | 
| 52 | 
            +
                    border-radius: 4px;
         | 
| 53 | 
            +
                    background-color: #007bff;
         | 
| 54 | 
            +
                    color: #fff;
         | 
| 55 | 
            +
                    cursor: pointer;
         | 
| 56 | 
            +
                  }
         | 
| 57 | 
            +
                  .history-button {
         | 
| 58 | 
            +
                    margin-top: 20px;
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                    padding: 10px 20px;
         | 
| 61 | 
            +
                    background-color: #007bff;
         | 
| 62 | 
            +
                    color: white;
         | 
| 63 | 
            +
                    border: none;
         | 
| 64 | 
            +
                    border-radius: 5px;
         | 
| 65 | 
            +
                    cursor: pointer;
         | 
| 66 | 
            +
                  }
         | 
| 67 | 
            +
                  history-button:hover {
         | 
| 68 | 
            +
                    background-color: #0056b3;
         | 
| 69 | 
            +
                  }
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                  .flex {
         | 
| 72 | 
            +
                    display: flex;
         | 
| 73 | 
            +
                    justify-content: center;
         | 
| 74 | 
            +
                  }
         | 
| 75 | 
            +
                  .new-person {
         | 
| 76 | 
            +
                    text-align: center;
         | 
| 77 | 
            +
                  }
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                  .controls {
         | 
| 80 | 
            +
                    display: flex;
         | 
| 81 | 
            +
                    flex-direction: column;
         | 
| 82 | 
            +
                    align-items: center;
         | 
| 83 | 
            +
                  }
         | 
| 84 | 
            +
                  .record-button {
         | 
| 85 | 
            +
                    width: 80px;
         | 
| 86 | 
            +
                    height: 80px;
         | 
| 87 | 
            +
                    background-color: transparent;
         | 
| 88 | 
            +
                    border-radius: 50%;
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                    display: flex;
         | 
| 91 | 
            +
                    justify-content: center;
         | 
| 92 | 
            +
                    align-items: center;
         | 
| 93 | 
            +
                    cursor: pointer;
         | 
| 94 | 
            +
                    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
         | 
| 95 | 
            +
                    transition: all 0.2s ease;
         | 
| 96 | 
            +
                  }
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                  .record-icon {
         | 
| 99 | 
            +
                    width: 60px;
         | 
| 100 | 
            +
                    height: 60px;
         | 
| 101 | 
            +
                    background-color: #d32f2f;
         | 
| 102 | 
            +
                    border-radius: 50%;
         | 
| 103 | 
            +
                    transition: all 0.2s ease;
         | 
| 104 | 
            +
                  }
         | 
| 105 | 
            +
             | 
| 106 | 
            +
                  .recording .record-icon {
         | 
| 107 | 
            +
                    width: 40px;
         | 
| 108 | 
            +
                    height: 40px;
         | 
| 109 | 
            +
                    border-radius: 10%;
         | 
| 110 | 
            +
                  }
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                  .record-p {
         | 
| 113 | 
            +
                    border: 2px dashed #0000008c;
         | 
| 114 | 
            +
                  }
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                  .disabled {
         | 
| 117 | 
            +
                    background-color: gray;
         | 
| 118 | 
            +
                    cursor: not-allowed;
         | 
| 119 | 
            +
                  }
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                  .record-icon.recording {
         | 
| 122 | 
            +
                    width: 40px;
         | 
| 123 | 
            +
                    height: 40px;
         | 
| 124 | 
            +
                    border-radius: 0;
         | 
| 125 | 
            +
                  }
         | 
| 126 | 
            +
             | 
| 127 | 
            +
                  .new-person-right-container {
         | 
| 128 | 
            +
                    padding-left: 20px;
         | 
| 129 | 
            +
                  }
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                  .record-container {
         | 
| 132 | 
            +
                    display: flex;
         | 
| 133 | 
            +
                    justify-content: center;
         | 
| 134 | 
            +
                  }
         | 
| 135 | 
            +
                </style>
         | 
| 136 | 
             
                <title>ユーザー登録画面</title>
         | 
| 137 | 
             
              </head>
         | 
| 138 | 
             
              <body>
         | 
    	
        templates/resetting_password.html
    ADDED
    
    | @@ -0,0 +1,54 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            <!DOCTYPE html>
         | 
| 2 | 
            +
            <html lang="ja">
         | 
| 3 | 
            +
              <head>
         | 
| 4 | 
            +
                <meta charset="UTF-8" />
         | 
| 5 | 
            +
                <meta name="viewport" content="width=device-width, initial-scale=1.0" />
         | 
| 6 | 
            +
                <title>パスワード再設定画面</title>
         | 
| 7 | 
            +
                <link rel="stylesheet" href="style.css">
         | 
| 8 | 
            +
                
         | 
| 9 | 
            +
              </head>
         | 
| 10 | 
            +
              <body>
         | 
| 11 | 
            +
                <form method="POST">
         | 
| 12 | 
            +
                  <div class="container">
         | 
| 13 | 
            +
                    <h2>パスワード再設定</h2>
         | 
| 14 | 
            +
                    <div>
         | 
| 15 | 
            +
                      <label for="">ユーザ名</label>
         | 
| 16 | 
            +
                      <input type="text" name="username" />
         | 
| 17 | 
            +
                      <br />
         | 
| 18 | 
            +
                      <br />
         | 
| 19 | 
            +
                      <label for="">パスワード</label>
         | 
| 20 | 
            +
                      <input type="password" name="password" />
         | 
| 21 | 
            +
                      <br />
         | 
| 22 | 
            +
                    </div>
         | 
| 23 | 
            +
                    <div class="flex">
         | 
| 24 | 
            +
                      <input
         | 
| 25 | 
            +
                        type="submit"
         | 
| 26 | 
            +
                        class="history-button"
         | 
| 27 | 
            +
                        id="loginButton"
         | 
| 28 | 
            +
                        onclick="showRecorder()"
         | 
| 29 | 
            +
                        value="パスワード再設定"
         | 
| 30 | 
            +
                      />
         | 
| 31 | 
            +
                    </div>
         | 
| 32 | 
            +
                </form>
         | 
| 33 | 
            +
               
         | 
| 34 | 
            +
                </div>
         | 
| 35 | 
            +
               
         | 
| 36 | 
            +
                
         | 
| 37 | 
            +
                
         | 
| 38 | 
            +
                <script>
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  // 初期化処理
         | 
| 41 | 
            +
                  displayTranscription();
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  //画面遷移
         | 
| 44 | 
            +
                  function showRecorder() {
         | 
| 45 | 
            +
                    // 録音画面へ遷移
         | 
| 46 | 
            +
                    window.location.href = "/index";
         | 
| 47 | 
            +
                  }
         | 
| 48 | 
            +
                  function showFeedback() {
         | 
| 49 | 
            +
                    // フィードバック画面へ遷移
         | 
| 50 | 
            +
                    window.location.href = "/feedback";
         | 
| 51 | 
            +
                  }
         | 
| 52 | 
            +
                </script>
         | 
| 53 | 
            +
              </body>
         | 
| 54 | 
            +
            </html>
         | 
    	
        users.py
    ADDED
    
    | @@ -0,0 +1,17 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
             | 
| 2 | 
            +
            from flask_login import UserMixin
         | 
| 3 | 
            +
            from database import db 
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class Users(UserMixin, db.Model):
         | 
| 6 | 
            +
                '''
         | 
| 7 | 
            +
                Users Table Model
         | 
| 8 | 
            +
                '''
         | 
| 9 | 
            +
                __tablename__ = 'users'
         | 
| 10 | 
            +
                id = db.Column(db.Integer, primary_key=True)
         | 
| 11 | 
            +
                username = db.Column(db.String(255), nullable=False, unique=True)
         | 
| 12 | 
            +
                password = db.Column(db.String(255))
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                def __init__(self,username,password):
         | 
| 15 | 
            +
                    self.username = username
         | 
| 16 | 
            +
                    self.password = password
         | 
| 17 | 
            +
                 
         |