목록버그바운티 스터디/FLASK (8)
kaki1013
# 예시 코드 from flask import Flask, request, redirect app = Flask(__name__) nextId = 4 topics = [ {'id': 1, 'title': 'html', 'body': 'html is ...'}, {'id': 2, 'title': 'css', 'body': 'css is ...'}, {'id': 3, 'title': 'javascript', 'body': 'javascript is ...'} ] def template(contents, content, id=None): contextUI = '' if id != None: contextUI = f''' update ''' return f''' WEB {contents} {content} cr..
# 예시 코드 from flask import Flask, request, redirect app = Flask(__name__) nextId = 4 topics = [ {'id': 1, 'title': 'html', 'body': 'html is ...'}, {'id': 2, 'title': 'css', 'body': 'css is ...'}, {'id': 3, 'title': 'javascript', 'body': 'javascript is ...'} ] def template(contents, content, id=None): contextUI = '' if id != None: contextUI = f''' update ''' return f''' WEB {contents} {content} cr..
# 예시 코드 from flask import Flask, request, redirect app = Flask(__name__) nextId = 4 topics = [ {'id': 1, 'title': 'html', 'body': 'html is ...'}, {'id': 2, 'title': 'css', 'body': 'css is ...'}, {'id': 3, 'title': 'javascript', 'body': 'javascript is ...'} ] def template(contents, content): return f''' WEB {contents} {content} create ''' def getContents(): liTags = '' for topic in topics: liTags..
# 쓰기 칸 만들기 1. 예시 코드 from flask import Flask app = Flask(__name__) topics = [ {'id': 1, 'title': 'html', 'body': 'html is ...'}, {'id': 2, 'title': 'css', 'body': 'css is ...'}, {'id': 3, 'title': 'javascript', 'body': 'javascript is ...'} ] def template(contents, content): return f''' WEB {contents} {content} create ''' def getContents(): liTags = '' for topic in topics: liTags = liTags + f'{top..
# 예시 코드 from flask import Flask app = Flask(__name__) # 코드 실행 종료 시, 작성된 내용이 초기화 됨 -> 실제로는 데이터베이스 이용 topics = [ {'id': 1, 'title': 'html', 'body': 'html is ...'}, {'id': 2, 'title': 'css', 'body': 'css is ...'}, {'id': 3, 'title': 'javascript', 'body': 'javascript is ...'} ] # 유지보수의 편의성을 위해서 기본 HTML 코드를 템플릿화 def template(contents, content): return f''' WEB {contents} {content} ''' def getContents..
# 예시 코드 from flask import Flask app = Flask(__name__) topics = [ {'id': 1, 'title': 'html', 'body': 'html is ...'}, {'id': 2, 'title': 'css', 'body': 'css is ...'}, {'id': 3, 'title': 'javascruot', 'body': 'javascript is ...'} ] @app.route('/') def index(): liTags = '' for topic in topics: liTags = liTags + f'{topic["title"]}' return f''' WEB {liTags} Welcome Hello, Web ''' @app.route('/create/'..

# 요약 1. 웹 프레임워크를 배울 때 처음으로 찾아봐야 할 것 = 이 웹 프레임 워크는 라우팅을 어떻게 하나? 2. Routing = 사용자의 요청을 어떤 함수가 응답할 것인가를 연결하는 작업 3. @app.route()를 이용해서 경로를 지정 → 그 아래의 함수가 요청을 처리할 함수로 지정됨 4. URL 경로 상에서 변하는 부분이 있다면 의 형식으로 패턴을 지정 가능 5. 자세한 내용은 아래 링크 참고 https://flask.palletsprojects.com/en/2.3.x/quickstart/#routing Quickstart — Flask Documentation (2.3.x) Quickstart Eager to get started? This page gives a good introduct..
# 수업소개 - 웹 프레임워크를 사용하는 이유 1. 예시 기본 틀이 동일한 1억개의 html이 내부적으로 하이퍼링크로 연결되어 있다고 가정 이때 페이지가 하나 추가되면 모든 문서에 1억 1번째 하이퍼링크 연결해야 함 → 한번에 처리할 수 없을까? 사용자들의 투고를 받아서 운영, 수정하려면? 모두 메일로 받는게 아니라 사용자가 입력 양식에 내용을 입력하여 저장하고, 페이지로 만들 수 있다면? 또한, 사용자를 구분해서 최적화된 웹 페이지를 보여줄 수 있다면? -> 파이썬으로 사용자의 요청이 들어올 때마다 웹페이지를 순간적으로 찍어내서 서비스하는 웹 공장을 만들자! 2. 주요 내용 파이썬으로 모두 만들 수 있지만 어려움 공통적인 부분은 웹 프레임워크에게 맡기고, 애플리케이션이 가진 개성을 만드는 데에 집중 (..