├── .DS_Store ├── .gitattributes ├── AWS ├── README.md ├── c9-apache.conf ├── c9-apache2.conf ├── database.php ├── index.array.php ├── index.html ├── index.if.php ├── index.json.php ├── jmeter-5.3.zip ├── lambda.py ├── lambda_text.json ├── loadtest.php ├── locustfile.py ├── php-mysql.php ├── sdk │ ├── index.php │ ├── write.php │ └── write_process.php ├── simple.php └── topic.json ├── Snipaste_2019-10-31_12-21-35.png ├── cloudfront.png ├── flask ├── app.mysql.py ├── app.sqlite3.py ├── data.sql └── topics.db ├── kdiff-merge-configure.png └── mysql └── employees.zip /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egoingsb/offline/6cbf4f958c40fbf3ddff96fad579e9170799142c/.DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | AWS/jmeter-5.3 filter=lfs diff=lfs merge=lfs -text 2 | -------------------------------------------------------------------------------- /AWS/README.md: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /AWS/c9-apache.conf: -------------------------------------------------------------------------------- 1 | 2 | # The ServerName directive sets the request scheme, hostname and port that 3 | # the server uses to identify itself. This is used when creating 4 | # redirection URLs. In the context of virtual hosts, the ServerName 5 | # specifies what hostname must appear in the request's Host: header to 6 | # match this virtual host. For the default virtual host (this file) this 7 | # value is not decisive as it is used as a last resort host regardless. 8 | # However, you must set it for any further virtual host explicitly. 9 | #ServerName www.example.com 10 | 11 | ServerAdmin webmaster@localhost 12 | DocumentRoot /home/ubuntu/environment 13 | 14 | # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, 15 | # error, crit, alert, emerg. 16 | # It is also possible to configure the loglevel for particular 17 | # modules, e.g. 18 | #LogLevel info ssl:warn 19 | 20 | ErrorLog ${APACHE_LOG_DIR}/error.log 21 | CustomLog ${APACHE_LOG_DIR}/access.log combined 22 | 23 | # For most configuration files from conf-available/, which are 24 | # enabled or disabled at a global level, it is possible to 25 | # include a line for only one particular virtual host. For example the 26 | # following line enables the CGI configuration for this host only 27 | # after it has been globally disabled with "a2disconf". 28 | #Include conf-available/serve-cgi-bin.conf 29 | 30 | -------------------------------------------------------------------------------- /AWS/c9-apache2.conf: -------------------------------------------------------------------------------- 1 | # This is the main Apache server configuration file. It contains the 2 | # configuration directives that give the server its instructions. 3 | # See http://httpd.apache.org/docs/2.4/ for detailed information about 4 | # the directives and /usr/share/doc/apache2/README.Debian about Debian specific 5 | # hints. 6 | # 7 | # 8 | # Summary of how the Apache 2 configuration works in Debian: 9 | # The Apache 2 web server configuration in Debian is quite different to 10 | # upstream's suggested way to configure the web server. This is because Debian's 11 | # default Apache2 installation attempts to make adding and removing modules, 12 | # virtual hosts, and extra configuration directives as flexible as possible, in 13 | # order to make automating the changes and administering the server as easy as 14 | # possible. 15 | 16 | # It is split into several files forming the configuration hierarchy outlined 17 | # below, all located in the /etc/apache2/ directory: 18 | # 19 | # /etc/apache2/ 20 | # |-- apache2.conf 21 | # | `-- ports.conf 22 | # |-- mods-enabled 23 | # | |-- *.load 24 | # | `-- *.conf 25 | # |-- conf-enabled 26 | # | `-- *.conf 27 | # `-- sites-enabled 28 | # `-- *.conf 29 | # 30 | # 31 | # * apache2.conf is the main configuration file (this file). It puts the pieces 32 | # together by including all remaining configuration files when starting up the 33 | # web server. 34 | # 35 | # * ports.conf is always included from the main configuration file. It is 36 | # supposed to determine listening ports for incoming connections which can be 37 | # customized anytime. 38 | # 39 | # * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/ 40 | # directories contain particular configuration snippets which manage modules, 41 | # global configuration fragments, or virtual host configurations, 42 | # respectively. 43 | # 44 | # They are activated by symlinking available configuration files from their 45 | # respective *-available/ counterparts. These should be managed by using our 46 | # helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See 47 | # their respective man pages for detailed information. 48 | # 49 | # * The binary is called apache2. Due to the use of environment variables, in 50 | # the default configuration, apache2 needs to be started/stopped with 51 | # /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not 52 | # work with the default configuration. 53 | 54 | 55 | # Global configuration 56 | # 57 | 58 | # 59 | # ServerRoot: The top of the directory tree under which the server's 60 | # configuration, error, and log files are kept. 61 | # 62 | # NOTE! If you intend to place this on an NFS (or otherwise network) 63 | # mounted filesystem then please read the Mutex documentation (available 64 | # at ); 65 | # you will save yourself a lot of trouble. 66 | # 67 | # Do NOT add a slash at the end of the directory path. 68 | # 69 | #ServerRoot "/etc/apache2" 70 | 71 | # 72 | # The accept serialization lock file MUST BE STORED ON A LOCAL DISK. 73 | # 74 | #Mutex file:${APACHE_LOCK_DIR} default 75 | 76 | # 77 | # The directory where shm and other runtime files will be stored. 78 | # 79 | 80 | DefaultRuntimeDir ${APACHE_RUN_DIR} 81 | 82 | # 83 | # PidFile: The file in which the server should record its process 84 | # identification number when it starts. 85 | # This needs to be set in /etc/apache2/envvars 86 | # 87 | PidFile ${APACHE_PID_FILE} 88 | 89 | # 90 | # Timeout: The number of seconds before receives and sends time out. 91 | # 92 | Timeout 300 93 | 94 | # 95 | # KeepAlive: Whether or not to allow persistent connections (more than 96 | # one request per connection). Set to "Off" to deactivate. 97 | # 98 | KeepAlive On 99 | 100 | # 101 | # MaxKeepAliveRequests: The maximum number of requests to allow 102 | # during a persistent connection. Set to 0 to allow an unlimited amount. 103 | # We recommend you leave this number high, for maximum performance. 104 | # 105 | MaxKeepAliveRequests 100 106 | 107 | # 108 | # KeepAliveTimeout: Number of seconds to wait for the next request from the 109 | # same client on the same connection. 110 | # 111 | KeepAliveTimeout 5 112 | 113 | 114 | # These need to be set in /etc/apache2/envvars 115 | User ${APACHE_RUN_USER} 116 | Group ${APACHE_RUN_GROUP} 117 | 118 | # 119 | # HostnameLookups: Log the names of clients or just their IP addresses 120 | # e.g., www.apache.org (on) or 204.62.129.132 (off). 121 | # The default is off because it'd be overall better for the net if people 122 | # had to knowingly turn this feature on, since enabling it means that 123 | # each client request will result in AT LEAST one lookup request to the 124 | # nameserver. 125 | # 126 | HostnameLookups Off 127 | 128 | # ErrorLog: The location of the error log file. 129 | # If you do not specify an ErrorLog directive within a 130 | # container, error messages relating to that virtual host will be 131 | # logged here. If you *do* define an error logfile for a 132 | # container, that host's errors will be logged there and not here. 133 | # 134 | ErrorLog ${APACHE_LOG_DIR}/error.log 135 | 136 | # 137 | # LogLevel: Control the severity of messages logged to the error_log. 138 | # Available values: trace8, ..., trace1, debug, info, notice, warn, 139 | # error, crit, alert, emerg. 140 | # It is also possible to configure the log level for particular modules, e.g. 141 | # "LogLevel info ssl:warn" 142 | # 143 | LogLevel warn 144 | 145 | # Include module configuration: 146 | IncludeOptional mods-enabled/*.load 147 | IncludeOptional mods-enabled/*.conf 148 | 149 | # Include list of ports to listen on 150 | Include ports.conf 151 | 152 | 153 | # Sets the default security model of the Apache2 HTTPD server. It does 154 | # not allow access to the root filesystem outside of /usr/share and /var/www. 155 | # The former is used by web applications packaged in Debian, 156 | # the latter may be used for local directories served by the web server. If 157 | # your system is serving content from a sub-directory in /srv you must allow 158 | # access here, or in any related virtual host. 159 | 160 | Options FollowSymLinks 161 | AllowOverride None 162 | Require all denied 163 | 164 | 165 | 166 | AllowOverride None 167 | Require all granted 168 | 169 | 170 | 171 | Options Indexes FollowSymLinks 172 | AllowOverride None 173 | Require all granted 174 | 175 | 176 | 177 | Options Indexes FollowSymLinks 178 | AllowOverride None 179 | Require all granted 180 | 181 | 182 | 183 | # 184 | # Options Indexes FollowSymLinks 185 | # AllowOverride None 186 | # Require all granted 187 | # 188 | 189 | 190 | 191 | 192 | # AccessFileName: The name of the file to look for in each directory 193 | # for additional configuration directives. See also the AllowOverride 194 | # directive. 195 | # 196 | AccessFileName .htaccess 197 | 198 | # 199 | # The following lines prevent .htaccess and .htpasswd files from being 200 | # viewed by Web clients. 201 | # 202 | 203 | Require all denied 204 | 205 | 206 | 207 | # 208 | # The following directives define some format nicknames for use with 209 | # a CustomLog directive. 210 | # 211 | # These deviate from the Common Log Format definitions in that they use %O 212 | # (the actual bytes sent including headers) instead of %b (the size of the 213 | # requested file), because the latter makes it impossible to detect partial 214 | # requests. 215 | # 216 | # Note that the use of %{X-Forwarded-For}i instead of %h is not recommended. 217 | # Use mod_remoteip instead. 218 | # 219 | LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined 220 | LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined 221 | LogFormat "%h %l %u %t \"%r\" %>s %O" common 222 | LogFormat "%{Referer}i -> %U" referer 223 | LogFormat "%{User-agent}i" agent 224 | 225 | # Include of directories ignores editors' and dpkg's backup files, 226 | # see README.Debian for details. 227 | 228 | # Include generic snippets of statements 229 | IncludeOptional conf-enabled/*.conf 230 | 231 | # Include the virtual host configurations: 232 | IncludeOptional sites-enabled/*.conf 233 | 234 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet 235 | -------------------------------------------------------------------------------- /AWS/database.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 |

CLOUD

8 |
    9 | 13 |
  • 14 | 17 |
18 | 21 | Hello is .. 22 | 27 |

28 | 29 | 32 | 35 | 36 | -------------------------------------------------------------------------------- /AWS/index.array.php: -------------------------------------------------------------------------------- 1 | 1, 'title'=>'html'), 4 | array('id'=>2, 'title'=>'css'), 5 | array('id'=>3, 'title'=>'js') 6 | ); 7 | ?> 8 | 9 | 10 | 11 | WEB1 12 | 13 | 14 | 15 |

WEB

16 |
    17 | {$item['title']}"); 20 | } 21 | ?> 22 |
23 | WelcomeHello, WEB'); 26 | } else{ 27 | foreach($list as $item){ 28 | if($item['id'] == $_GET['id']){ 29 | print("

{$item['title']}

{$item['title']}"); 30 | } 31 | } 32 | } 33 | ?> 34 | 35 | -------------------------------------------------------------------------------- /AWS/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

CLOUD

4 | 9 |

S3

10 | Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsa enim officiis fugit reprehenderit nobis amet aperiam! Pariatur, cupiditate dolorem maxime ad molestias aliquam delectus, dicta temporibus nobis quibusdam unde modi. 11 |

EC2

12 | Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptas, ea qui magnam quo aliquam aut animi esse deleniti, perferendis, voluptatum quidem nostrum officiis? Eligendi necessitatibus consequatur cupiditate ad non aspernatur! 13 |

CloudFront

14 | Lorem ipsum dolor sit amet consectetur adipisicing elit. Quae libero, id reprehenderit quidem asperiores repudiandae sequi porro magnam dolores explicabo ad sapiente omnis? Molestiae, harum. Eveniet deleniti quasi dolore repellendus. 15 | 16 | 17 | -------------------------------------------------------------------------------- /AWS/index.if.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WEB 5 | 6 | 7 | 8 |

WEB

9 |
    10 |
  1. html
  2. 11 |
  3. css
  4. 12 |
  5. js
  6. 13 |
14 | WelcomeHello, WEB'; 17 | }else if($_GET['id'] == '1'){ 18 | echo '

html

html is ...'; 19 | } else if($_GET['id'] == '2'){ 20 | echo '

css

css is ...'; 21 | } else if($_GET['id'] == '3'){ 22 | echo '

js

js is ...'; 23 | } 24 | ?> 25 | 26 | 27 | -------------------------------------------------------------------------------- /AWS/index.json.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | WEB1 9 | 10 | 11 | 12 |

WEB

13 |
    14 | {$item['title']}"); 17 | } 18 | ?> 19 |
20 | WelcomeHello, WEB'); 23 | } else{ 24 | foreach($list as $item){ 25 | if($item['id'] == $_GET['id']){ 26 | print("

{$item['title']}

{$item['title']}"); 27 | } 28 | } 29 | } 30 | ?> 31 | 32 | -------------------------------------------------------------------------------- /AWS/jmeter-5.3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egoingsb/offline/6cbf4f958c40fbf3ddff96fad579e9170799142c/AWS/jmeter-5.3.zip -------------------------------------------------------------------------------- /AWS/lambda.py: -------------------------------------------------------------------------------- 1 | import json 2 | def lambda_handler(event, context): 3 | print('event', 'pathParameters' in event); 4 | content = '

Welcome

Hello, WEB' 5 | if 'pathParameters' in event: 6 | id = event['pathParameters']['id'] 7 | if id == '1': 8 | content = '

HTML

HTML is ...' 9 | elif id == '2': 10 | content = '

CSS

CSS is ...' 11 | elif id == '3': 12 | content = '

JavaScript

JavaScript is ...' 13 | return { 14 | 'statusCode': 200, 15 | 'headers':{ 16 | 'Content-type': 'text/html' 17 | }, 18 | 'body': ''' 19 |

WEB

20 |
    21 |
  1. html
  2. 22 |
  3. css
  4. 23 |
24 | '''+content 25 | } -------------------------------------------------------------------------------- /AWS/lambda_text.json: -------------------------------------------------------------------------------- 1 | { 2 | "pathParameters": { 3 | "id": "1" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /AWS/loadtest.php: -------------------------------------------------------------------------------- 1 | empty($_GET['cost']) ? 14 : (int)$_GET['cost'])); 5 | echo 'IP address : '. $_SERVER['SERVER_ADDR'].'
'; 6 | echo '현재 시간 : '.date("Y-m-d h:i:sa").'
'; 7 | echo '소요 시간 : '.(microtime(true) - $time).'
'; 8 | ?> 9 | -------------------------------------------------------------------------------- /AWS/locustfile.py: -------------------------------------------------------------------------------- 1 | from locust import HttpUser, task 2 | 3 | class HelloWorldUser(HttpUser): 4 | @task 5 | def test(self): 6 | self.client.get("/loadtest.php") 7 | -------------------------------------------------------------------------------- /AWS/php-mysql.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 |

CLOUD

8 |
    9 | 13 |
  • 14 | 17 |
18 | 21 | Hello is .. 22 | 27 |

28 | 29 | 32 | 35 | 36 | -------------------------------------------------------------------------------- /AWS/sdk/index.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 |

CLOUD

8 |
    9 | 13 |
  • 14 | 17 |
18 | 21 | Hello is .. 22 | 27 |

28 | 29 |

30 | 33 | 36 | write 37 | 38 | -------------------------------------------------------------------------------- /AWS/sdk/write.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |

5 |

6 |

7 |

8 |
9 | 10 | -------------------------------------------------------------------------------- /AWS/sdk/write_process.php: -------------------------------------------------------------------------------- 1 | 'latest', 8 | 'region' => 'ap-northeast-2' 9 | ]); 10 | // Send a PutObject request and get the result object. 11 | $result = $s3Client->putObject([ 12 | 'ACL'=>'public-read', 13 | 'Bucket' => 'my-photo-server', 14 | 'Key' => $_FILES['uploaded_file']['name'], 15 | 'SourceFile' => $_FILES['uploaded_file']['tmp_name'] 16 | ]); 17 | $s3URL = $result->toArray()['ObjectURL']; 18 | $conn = mysqli_connect('db.cdbrt00yi2pz.ap-northeast-2.rds.amazonaws.com', 'admin', 'qwertyuiop', 'mydb'); 19 | $sql = "INSERT INTO topic (title, description, thumbnail) VALUES('{$_POST['title']}', '{$_POST['description']}', '{$s3URL}')"; 20 | mysqli_query($conn, $sql); 21 | header('Location: index.php'); 22 | ?> -------------------------------------------------------------------------------- /AWS/simple.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

CLOUD

4 | 9 | 20 | 21 | -------------------------------------------------------------------------------- /AWS/topic.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"id":1, "title":"HTML", "body":"HTML is .."}, 3 | {"id":2, "title":"CSS", "body":"CSS is .."}, 4 | {"id":3, "title":"JS", "body":"JS is .."} 5 | ] -------------------------------------------------------------------------------- /Snipaste_2019-10-31_12-21-35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egoingsb/offline/6cbf4f958c40fbf3ddff96fad579e9170799142c/Snipaste_2019-10-31_12-21-35.png -------------------------------------------------------------------------------- /cloudfront.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egoingsb/offline/6cbf4f958c40fbf3ddff96fad579e9170799142c/cloudfront.png -------------------------------------------------------------------------------- /flask/app.mysql.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, redirect 2 | import time 3 | import pymysql 4 | 5 | app = Flask(__name__) 6 | 7 | DB_HOST="database-1.cdbrt00yi2pz.ap-northeast-2.rds.amazonaws.com" 8 | DB_USER="admin" 9 | DB_PASS="11111111" 10 | DB_DATABASE="myflask" 11 | 12 | 13 | @app.route('/create_process', methods=['POST']) 14 | def create_process(): 15 | cnt = pymysql.connect(host=DB_HOST,user=DB_USER,password=DB_PASS,database=DB_DATABASE) 16 | cursor=cnt.cursor() 17 | title = request.form.get('title') 18 | body = request.form.get('body') 19 | sql = "INSERT INTO topic (title, body) VALUES('"+title+"','"+body+"')" 20 | result = cursor.execute(sql) 21 | cnt.commit() 22 | url = '/read/'+str(cursor.lastrowid) 23 | return redirect(url) 24 | 25 | @app.route('/delete_process', methods=['POST']) 26 | def delete_process(): 27 | cnt = pymysql.connect(host=DB_HOST,user=DB_USER,password=DB_PASS,database=DB_DATABASE) 28 | cursor = cnt.cursor() 29 | id = request.form.get('id') 30 | sql = "DELETE FROM topic WHERE id="+id 31 | result = cursor.execute(sql) 32 | cnt.commit() 33 | return redirect('/') 34 | 35 | @app.route('/update_process', methods=['POST']) 36 | def update_process(): 37 | cnt = pymysql.connect(host=DB_HOST,user=DB_USER,password=DB_PASS,database=DB_DATABASE) 38 | cursor = cnt.cursor() 39 | id = request.form.get('id') 40 | title = request.form.get('title') 41 | body = request.form.get('body') 42 | sql = "UPDATE topic SET title='"+title+"', body='"+body+"' WHERE id="+id 43 | result = cursor.execute(sql) 44 | cnt.commit() 45 | return redirect('/read/'+id) 46 | 47 | @app.route('/update/') 48 | def update(topicid): 49 | cnt = pymysql.connect(host=DB_HOST,user=DB_USER,password=DB_PASS,database=DB_DATABASE) 50 | cursor=cnt.cursor() 51 | cursor.execute('SELECT id,title,body FROM topic') 52 | topics = cursor.fetchall() 53 | contents = '

Web

' 54 | contents += '
    ' 55 | for id, title,body in topics: 56 | contents += '
  1. '+title+'
  2. ' 57 | contents += '
' 58 | 59 | cursor=cnt.cursor() 60 | cursor.execute('SELECT * FROM topic WHERE id='+topicid) 61 | topic = cursor.fetchone() 62 | 63 | contents +='

Update

' 64 | contents += ''' 65 |
66 | 67 |

68 |

69 |

70 |
71 | ''' 72 | return contents 73 | 74 | @app.route('/create') 75 | def create(): 76 | cnt = pymysql.connect(host=DB_HOST,user=DB_USER,password=DB_PASS,database=DB_DATABASE) 77 | cursor=cnt.cursor() 78 | cursor.execute('SELECT id,title,body FROM topic') 79 | topics = cursor.fetchall() 80 | contents = '

Web

' 81 | contents += '
    ' 82 | for id, title,body in topics: 83 | contents += '
  1. '+title+'
  2. ' 84 | contents += '
' 85 | 86 | contents +='

Create

' 87 | contents += ''' 88 |
89 |

90 |

91 |

92 |
93 | ''' 94 | return contents 95 | 96 | @app.route('/read/') 97 | def read_topic(topicid ): 98 | cnt = pymysql.connect(host=DB_HOST,user=DB_USER,password=DB_PASS,database=DB_DATABASE) 99 | cursor=cnt.cursor() 100 | cursor.execute('SELECT id,title,body FROM topic') 101 | topics = cursor.fetchall() 102 | contents = '

Web

' 103 | contents += '
    ' 104 | for id, title, body in topics: 105 | contents += '
  1. '+title+'
  2. ' 106 | contents += '
' 107 | 108 | cursor=cnt.cursor() 109 | cursor.execute('SELECT id,title,body FROM topic WHERE id='+topicid) 110 | topic = cursor.fetchone() 111 | contents += '

'+topic[1]+'

'+topic[2] 112 | contents += '

create

' 113 | contents += '

update

' 114 | contents += ''' 115 |

116 |

117 | 118 | 119 |
120 |

''' 121 | return contents 122 | @app.route('/') 123 | def home(): 124 | cnt = pymysql.connect(host=DB_HOST,user=DB_USER,password=DB_PASS,database=DB_DATABASE) 125 | cursor=cnt.cursor() 126 | cursor.execute('SELECT id,title,body FROM topic') 127 | topics = cursor.fetchall() 128 | print('topics', topics) 129 | contents = '

Web

' 130 | contents += '
    ' 131 | for id, title, body in topics: 132 | contents += '
  1. '+title+'
  2. ' 133 | contents += '
' 134 | contents +='

Welcome

Hello, WEB' 135 | return contents+'

create

' 136 | 137 | app.run(debug=True,host="0.0.0.0",port="8000") 138 | -------------------------------------------------------------------------------- /flask/app.sqlite3.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, redirect 2 | import time 3 | import sqlite3 4 | 5 | 6 | app = Flask(__name__) 7 | 8 | 9 | @app.route('/create_process', methods=['POST']) 10 | def create_process(): 11 | cnt = sqlite3.connect('topics.db') 12 | title = request.form.get('title') 13 | body = request.form.get('body') 14 | sql = "INSERT INTO topic (title, body) VALUES('"+title+"','"+body+"')" 15 | result = cnt.execute(sql) 16 | cnt.commit() 17 | url = '/read/'+str(result.lastrowid) 18 | return redirect(url) 19 | 20 | @app.route('/delete_process', methods=['POST']) 21 | def delete_process(): 22 | cnt = sqlite3.connect('topics.db') 23 | id = request.form.get('id') 24 | sql = "DELETE FROM topic WHERE id="+id 25 | result = cnt.execute(sql) 26 | cnt.commit() 27 | return redirect('/') 28 | 29 | @app.route('/update_process', methods=['POST']) 30 | def update_process(): 31 | cnt = sqlite3.connect('topics.db') 32 | id = request.form.get('id') 33 | title = request.form.get('title') 34 | body = request.form.get('body') 35 | sql = "UPDATE topic SET title='"+title+"', body='"+body+"' WHERE id="+id 36 | print('sql', sql) 37 | result = cnt.execute(sql) 38 | cnt.commit() 39 | return redirect('/read/'+id) 40 | 41 | @app.route('/update/') 42 | def update(topicid): 43 | cnt = sqlite3.connect('topics.db') 44 | result = cnt.execute('SELECT * FROM topic') 45 | topics = result.fetchall() 46 | contents = '

Web

' 47 | contents += '
    ' 48 | for id, title,body in topics: 49 | contents += '
  1. '+title+'
  2. ' 50 | contents += '
' 51 | 52 | result = cnt.execute('SELECT * FROM topic WHERE id='+topicid) 53 | topic = result.fetchone() 54 | 55 | contents +='

Update

' 56 | contents += ''' 57 |
58 | 59 |

60 |

61 |

62 |
63 | ''' 64 | return contents 65 | 66 | @app.route('/create') 67 | def create(): 68 | cnt = sqlite3.connect('topics.db') 69 | result = cnt.execute('SELECT * FROM topic') 70 | topics = result.fetchall() 71 | contents = '

Web

' 72 | contents += '
    ' 73 | for id, title,body in topics: 74 | contents += '
  1. '+title+'
  2. ' 75 | contents += '
' 76 | 77 | contents +='

Create

' 78 | contents += ''' 79 |
80 |

81 |

82 |

83 |
84 | ''' 85 | return contents 86 | 87 | @app.route('/read/') 88 | def read_topic(topicid ): 89 | cnt = sqlite3.connect('topics.db') 90 | result = cnt.execute('SELECT * FROM topic') 91 | topics = result.fetchall() 92 | contents = '

Web

' 93 | contents += '
    ' 94 | for id, title,body in topics: 95 | contents += '
  1. '+title+'
  2. ' 96 | contents += '
' 97 | 98 | result = cnt.execute('SELECT * FROM topic WHERE id='+topicid) 99 | topic = result.fetchone() 100 | contents += '

'+topic[1]+'

'+topic[2] 101 | contents += '

create

' 102 | contents += '

update

' 103 | contents += ''' 104 |

105 |

106 | 107 | 108 |
109 |

''' 110 | return contents 111 | 112 | @app.route('/') 113 | def home(): 114 | cnt = sqlite3.connect('topics.db') 115 | result = cnt.execute('SELECT * FROM topic') 116 | topics = result.fetchall() 117 | print('topics', topics) 118 | contents = '

Web

' 119 | contents += '
    ' 120 | for id, title,body in topics: 121 | contents += '
  1. '+title+'
  2. ' 122 | contents += '
' 123 | contents +='

Welcome

Hello, WEB' 124 | return contents+'

create

' 125 | 126 | app.run(debug=True,host="0.0.0.0",port="8000") 127 | -------------------------------------------------------------------------------- /flask/data.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `topic` ( 2 | `id` INT NOT NULL AUTO_INCREMENT, 3 | `title` VARCHAR(20), 4 | `body` TEXT, 5 | PRIMARY KEY (`id`) 6 | ); 7 | INSERT INTO topic(title, body) VALUES('HTML', 'HTML is ...'); 8 | INSERT INTO topic(title, body) VALUES('CSS', 'CSS is ...'); 9 | INSERT INTO topic(title, body) VALUES('JS', 'JS is ...'); 10 | -------------------------------------------------------------------------------- /flask/topics.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egoingsb/offline/6cbf4f958c40fbf3ddff96fad579e9170799142c/flask/topics.db -------------------------------------------------------------------------------- /kdiff-merge-configure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egoingsb/offline/6cbf4f958c40fbf3ddff96fad579e9170799142c/kdiff-merge-configure.png -------------------------------------------------------------------------------- /mysql/employees.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egoingsb/offline/6cbf4f958c40fbf3ddff96fad579e9170799142c/mysql/employees.zip --------------------------------------------------------------------------------