본문 바로가기
PRACTICE/Basic

[Flask] escape, request 사용하여 웹에서 입력받은 값 출력

by 1005 2020. 9. 3.

 

 

< Flask Tutorial >

 

Flask Tutorial - Tutorialspoint

Flask 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 proje

www.tutorialspoint.com

 


1
2
3
4
5
6
7
8
9
10
11
12
13
from flask import Flask, escape, request
 
app = Flask(__name__) #생성자, 시작지점
@app.route('/'#루트경로
 
def mainPage(): #사용자 지정 함수
    #기본 출력값은 world, 웹에서 input값이 들어오면 input값을 출력
    name = request.args.get('input','world')     
    return f'Hello {escape(name)}' #name에 저장된 값을 웹에 출력. 
 
if __name__ == '__main__':
    app.run(host='0.0.0.0',debug=True, port='80')
 

 

기본값인 world 출력

 

input 입력값인 Flask 출력

 

 

댓글