0331

3477 ワード

1.学習内容


ctrl+/コメントのオン/オフ
通常はget、書く時はpost
titleとbodyはurlに表示されません
F 12-ネットワーク-ペイロード
リファレンス
フラスコ-クイックスタート-HSTP方法
https://seomal.com/map/1/16
리다이렉트
from flask import redirect

@app.route('/redirect/')
def a():
	return redirect('/')
topics = [~~~]
nextId = 4

from flask import request

@app.route('/create_process/', methods=['POST'])
def create_process():
	global nextId // 전역변수
	title = request.form['title']
	body = request.form['body']
	newTopic = {"id":nextId, "title":title, "body":body}
	topics.append(newTopic)
	nextId = nextId + 1
	//return f'success!! go:/read/{nextId-1}/'
	return redirect(f'/read/{nextId-1}/')
삭제
def template(content, id=None):
<li>
	<form action="/delete/{id}/" method="POST">
		<input type="submit" value="delete">
	</form>
</li>
  
def delete(id):
	for topic in topics:
		if topic['id'] == id:
			topics.remove(topic)
			break;
	return redirect('/')
SQLite
https://sqlitestudio.pl/
Add a Database-ファイル名.sqlite3
ターミナル
$ sqlite3
.open topics.sqlite3
.exit
出力.ls//ファイルリスト
$ sqlite3 topics.sqlite 3//トピックを開く
.tables
$ refresh
Create a table
Columnname:id/datatype:int/primary Key/一意識別子
Add column
commit structure changes
データの追加
//DDL
CREATE TABLE topics (
id INTEGER PRIMARY KEY,
title TEXT NOT NULL,
body TEXT
);
SQL editor
INSERT INTO topics (title, body) VALUES('ORACLE', 'ORACLE IS...')
行の追加

2.難しいところ


.

3.解決方法


.

4.勉強の心得


.