0331
1. 학습내용
ctrl + / 주석 켜고 끄기
보통은 get, 쓸 때는 post
title과 body가 url에 뜨지 않음 F12 - 네트워크 - 페이로드에 있음참고
플라스크 - Quick Start - HTTP Methods
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.sqlite3 // topics 열기
.tables
$ refresh
Create a table
Column name : id / Data type : 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. 학습소감
.
Author And Source
이 문제에 관하여(0331), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@ai3256/0331저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)