This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask, render_template | |
| from flask_sqlalchemy import SQLAlchemy | |
| app = Flask(__name__) | |
| # ========================================== | |
| # 1. データベース接続設定 | |
| # ========================================== | |
| # 接続先の設定 (products データベースへ接続) | |
| # ※パスワードやエンドポイントはご自身の環境に合わせて書き換えてください |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ========================================== | |
| # 0. 事前準備 (ターミナルで実行) | |
| # ========================================== | |
| # 必要なライブラリをインストールします | |
| # pip install flask flask-sqlalchemy mysql-connector-python | |
| from flask import Flask, render_template | |
| from flask_sqlalchemy import SQLAlchemy | |
| app = Flask(__name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ========================================== | |
| # 0. 事前準備 (ターミナルで実行) | |
| # ========================================== | |
| # 必要なライブラリをインストールします | |
| # pip install flask flask-sqlalchemy mysql-connector-python | |
| from flask import Flask, render_template | |
| from flask_sqlalchemy import SQLAlchemy | |
| app = Flask(__name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import mysql.connector | |
| from mysql.connector import Error | |
| import os | |
| # データベース接続設定 | |
| DB_CONFIG = { | |
| 'host': 'endpoint', | |
| 'user': 'admin', # ← 変更してください | |
| 'password': 'LinuxOS99', # ← 変更してください |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- データベース作成 | |
| CREATE DATABASE IF NOT EXISTS disaster_agreements_db DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; | |
| USE disaster_agreements_db; | |
| -- 区分マスタテーブル | |
| CREATE TABLE IF NOT EXISTS classifications ( | |
| id INT PRIMARY KEY, | |
| name VARCHAR(100) NOT NULL, | |
| created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- データベース作成 | |
| CREATE DATABASE IF NOT EXISTS disaster_agreements_db DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; | |
| USE disaster_agreements_db; | |
| -- 区分マスタテーブル | |
| CREATE TABLE IF NOT EXISTS classifications ( | |
| classification_id INT PRIMARY KEY, | |
| name VARCHAR(100) NOT NULL, | |
| created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="ja"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>{{ category.name }} | カテゴリ別アプリ一覧</title> | |
| </head> | |
| <body> | |
| <h1>カテゴリ:{{ category.name }}</h1> | |
| <h2>このカテゴリのアプリ一覧</h2> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="ja"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>{{ application.title }} | アプリ詳細</title> | |
| </head> | |
| <body> | |
| <h1>{{ application.title }}</h1> | |
| <p>カテゴリ:{{ application.category_name }}</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="ja"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>アプリ一覧</title> | |
| </head> | |
| <body> | |
| <h1>アプリ一覧</h1> | |
| {% if applications %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask, render_template | |
| import mysql.connector | |
| app = Flask(__name__) | |
| # データベース接続設定 | |
| db_config = { | |
| 'host': 'myendpoint.rds.amazonaws.com', | |
| 'user': 'admin', # あなたのMySQLユーザー名 | |
| 'password': 'pass', # あなたのMySQLパスワード |