Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -216,7 +216,7 @@ def show_data_gc(): | |
| 216 | 
             
                    total_users = cursor.fetchone()[0]
         | 
| 217 | 
             
                    conn.close()
         | 
| 218 |  | 
| 219 | 
            -
                    return render_template(' | 
| 220 | 
             
                except Exception as e:
         | 
| 221 | 
             
                    print(f"Error showing contacts: {e}")
         | 
| 222 | 
             
                    return "Internal Server Error", 500
         | 
| @@ -225,38 +225,16 @@ def show_data_gc(): | |
| 225 |  | 
| 226 |  | 
| 227 |  | 
| 228 | 
            -
             | 
| 229 | 
             
            @app.route('/data_gc_tab', methods=['GET'])
         | 
| 230 | 
             
            def data_gc_tab():
         | 
| 231 | 
            -
                 | 
| 232 | 
            -
             | 
|  | |
|  | |
| 233 |  | 
| 234 | 
            -
                    if api_sys_control != api_key_sys:
         | 
| 235 | 
            -
                        return "EUR 22", 200
         | 
| 236 |  | 
| 237 | 
            -
                    conn = sqlite3.connect('data_gc.db')
         | 
| 238 | 
            -
                    cursor = conn.cursor()
         | 
| 239 | 
            -
                    cursor.execute('SELECT name, phone, email FROM contacts')
         | 
| 240 | 
            -
                    contacts = cursor.fetchall()
         | 
| 241 | 
            -
                    conn.close()
         | 
| 242 |  | 
| 243 | 
            -
                    contacts_json = [{'name': contact[0], 'phone': contact[1], 'email': contact[2]} for contact in contacts]
         | 
| 244 | 
            -
                    return jsonify(contacts_json), 200
         | 
| 245 | 
            -
                except Exception as e:
         | 
| 246 | 
            -
                    print(f"Error getting data from data_gc: {e}")
         | 
| 247 | 
            -
                    return "Internal Server Error", 500
         | 
| 248 |  | 
| 249 | 
            -
            def get_total_users():
         | 
| 250 | 
            -
                try:
         | 
| 251 | 
            -
                    conn = sqlite3.connect('data_gc.db')
         | 
| 252 | 
            -
                    cursor = conn.cursor()
         | 
| 253 | 
            -
                    cursor.execute('SELECT COUNT(*) FROM contacts')
         | 
| 254 | 
            -
                    total_users = cursor.fetchone()[0]
         | 
| 255 | 
            -
                    conn.close()
         | 
| 256 | 
            -
                    return total_users
         | 
| 257 | 
            -
                except Exception as e:
         | 
| 258 | 
            -
                    print(f"Error getting total users: {e}")
         | 
| 259 | 
            -
                    return 0
         | 
| 260 |  | 
| 261 |  | 
| 262 |  | 
| @@ -266,6 +244,7 @@ def get_total_users(): | |
| 266 |  | 
| 267 |  | 
| 268 |  | 
|  | |
| 269 |  | 
| 270 |  | 
| 271 | 
             
            @app.route('/data_ras')
         | 
|  | |
| 216 | 
             
                    total_users = cursor.fetchone()[0]
         | 
| 217 | 
             
                    conn.close()
         | 
| 218 |  | 
| 219 | 
            +
                    return render_template('data_gc.html', contacts=contacts, total_users=total_users)
         | 
| 220 | 
             
                except Exception as e:
         | 
| 221 | 
             
                    print(f"Error showing contacts: {e}")
         | 
| 222 | 
             
                    return "Internal Server Error", 500
         | 
|  | |
| 225 |  | 
| 226 |  | 
| 227 |  | 
|  | |
| 228 | 
             
            @app.route('/data_gc_tab', methods=['GET'])
         | 
| 229 | 
             
            def data_gc_tab():
         | 
| 230 | 
            +
                api_sys_control = request.args.get('api_sys')
         | 
| 231 | 
            +
                if api_sys_control != api_key_sys:
         | 
| 232 | 
            +
                    return "EUR 22", 200
         | 
| 233 | 
            +
                return render_template('data_gc_tab.html')
         | 
| 234 |  | 
|  | |
|  | |
| 235 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 236 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 237 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 238 |  | 
| 239 |  | 
| 240 |  | 
|  | |
| 244 |  | 
| 245 |  | 
| 246 |  | 
| 247 | 
            +
                    
         | 
| 248 |  | 
| 249 |  | 
| 250 | 
             
            @app.route('/data_ras')
         |