본문 바로가기

분류 전체보기94

[Flask] jinja template 활용하여 static 폴더의 자료 가져오기 1234567891011121314 # jinja 탬플릿을 활용하여 static 폴더의 자료를 가져오는 예제.  from flask import Flask from flask import render_template app = Flask(__name__) @app.route('/')def index():   return render_template('index.html') if __name__ == '__main__':   app.run(host='0.0.0.0', port = 80, debug = True)     1234567891011121314!DOCTYPE html>html lang="ko">head>    meta charset="UTF-8">    meta name="viewport" con.. 2020. 9. 24.
[Flask] request.form 사용하여 key, value 값 전달 123456789101112131415from flask import Flask, render_template, requestapp = Flask(__name__) @app.route('/')def student():   return render_template('addrbook.html') @app.route('/pbook',methods = ['POST', 'GET'])def result():   if request.method == 'POST':      val = request.form #addrbook.html에서 name을 통해 submit한 값들을 val 객체로 전달      return render_template("pbook.html",result = val) #name은 key, nam.. 2020. 9. 23.
[HTML] < a href = "사이트 주소" target= "blink" ></a> 123456789101112!DOCTYPE html>html>head>    meta charset='utf-8'>    title>HTML 태그의 속성/title>  /head>body>    a href="http://www.naver.com" target="blink">네이버 사이트로 이동/a>         a href="http://www.daum.net">다음 사이트로 이동/a> /body>/html>Colored by Color Scripter 2020. 9. 10.
[HTML] 웹 개념 정리 1) URL (Uniform Resource Locator): 인터넷에 연결된 정보에 접근하기 위해 사용하는 주소 형식을 가리키는 말.   2) IP (Information Provider): 주소를 기억하기 쉽게 의미를 파악할 수 있는 상징적인 문자로 구성한 주소. 3) 서버 프로그램, 클라이언트 프로그램 * 서버 프로그램: 자바, C#, 루비, 파이썬, 자바스크립트      - 웹 프레임워크(ASP.NET, JSP, PHP 등)     - MVC 프레임워크(ASP.NET MVC, Spring MVC, Ruby on Rails 등)     - 비동기 프레임워크(Node.js Express, Jetty) * 클라이언트 프로그램     - 반드시 HTML, CSS, 자바스크립트로 개발  4) MVC 패턴 .. 2020. 9. 4.
[Flask] 컬렉션(Dictionary), Jinja template(%) 사용하여 score table 출력 Template Designer Documentation — Jinja Documentation (2.11.x)This document describes the syntax and semantics of the template engine and will be most useful as reference to those creating Jinja templates. As the template engine is very flexible, the configuration from the application can be slightly different from tjinja.palletsprojects.com  12345678910from flask import Flask, render_templateap.. 2020. 9. 3.
[Flask] request 사용하여 POST, GET 출력 123456789101112131415161718from flask import Flask, redirect, url_for, requestapp = Flask(__name__) @app.route('/success/')def success(name):   return 'welcome %s' % name @app.route('/login',methods = ['POST', 'GET'])def login():   if request.method == 'POST':      user = request.form['nm']      return redirect(url_for('success',name = user))   else:      user = request.args.get('nm')      retur.. 2020. 9. 3.
[Flask] url_for, redirect 사용하여 main, major, minor 페이지 출력 #app.route 함수실행 호출 --> url_for1234567891011121314151617181920212223242526#모듈 추가 from flask import Flask, url_for, redirect #웹앱 생성app= Flask(__name__) #프로젝트 객체 생성 @app.route('/major')def major():    return 'Major Page'@app.route('/minor')def minor():    return 'Minor Page'@app.route('/')def index_page(id):    if id == 'root':        return redirect(url_for('major'))    else:        return redirec.. 2020. 9. 3.
[Flask] int, float값 구분하여 웹 페이지 호출 123456789101112131415#변수규칙 from flask import Flask, render_templateapp = Flask(__name__) @app.route('/blog/') #웹에서 postID라는 값을 받음.def show_blog(postID): #받아온 postID를 파이썬 매개변수로 사용.   return 'Blog Number %d' % postID #html에 출력. @app.route('/rev/')def revision(revNo):   return 'Revision Number %f' % revNo if __name__ == '__main__':   app.run(host='0.0.0.0',port='80',debug=True) 2020. 9. 3.
[Flask] render_template 사용하여 count 출력 # 경로 렌더링 render_template# 꼭 templates 폴더를 만들어 주어야 함.  1234567891011121314from flask import Flask, render_template app = Flask(__name__) cnt = 0 #전역변수 @app.route('/')def count():    global cnt #전역변수를 함수 내에서 사용하기 위해 global 붙여줌.    cnt += 1    return render_template('count.html',cnt = cnt) if __name__ == '__main__':    app.run(host='0.0.0.0',debug=True, port='80') Colored by Color Scripter   12345h.. 2020. 9. 3.
[Flask] escape, request 사용하여 웹에서 입력받은 값 출력 Flask Tutorial - TutorialspointFlask Tutorial Flask is a web application framework written in Python. Armin Ronacher, who leads an international group of Python enthusiasts named Pocco, develops it. Flask is based on Werkzeug WSGI toolkit and Jinja2 template engine. Both are Pocco projewww.tutorialspoint.com 12345678910111213from flask import Flask, escape, request app = Flask(__name__) #생성자, 시작.. 2020. 9. 3.