pip install flask

모듈이랑 이름이 같으면 안됨
myflask로 바꿨음
폴더만들기

from flask import Flask, render_template

app = Flask(__name__)

#라우팅
@app.route('/')
def hello():

    return render_template('index.html')

if __name__ == '__main__':
    app.run()

 

터미널에서 python myflask.py 실행시키면 

 

파란색 누르면 
들어가짐 

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <title>홈 페이지</title>
</head>
<body>
    <h3>홈 페이지 환영합니다</h3>
    <table border="1" bordercolor="blue">
        <tr>
            <td>
                서적 제목
            </td>
            <td>
                <input type="text" name="title">
            </td>
        </tr>
        <tr>
            <td>
                서적 표지
            </td>
            <td>
                <input type="file" name="photo">
            </td>
        </tr>
        <tr>
            <td>
                서적 저자
            </td>
            <td>
                <input type="text" name="author">
            </td>
        </tr>
        <tr>
            <td>
                서적 출간일자
            </td>
            <td>
                <input type="text" name="created_date">
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" value="등 록">
            </td>

        </tr>
    </table>
</body>
</html>

- 실행시키면 


 

-web.py 

from flask import Flask, render_template
app = Flask(__name__)


@app.route("/")
def index():

    return render_template('index.html')


@app.route("/two_input")
def two_input():

    return render_template('two_input.html')


if __name__ == "__main__":
    app.run()

 

-two_input.html

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <title>2개 값 입력</title>
</head>
<body>

    <table border="1" bordercolor="blue">
        <tr>
            <td>
                값1
            </td>
            <td>
                <input type="text" name="value1">
            </td>
        </tr>
        <tr>
            <td>
                값2
            </td>
            <td>
                <input type="text" name="value2">
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" value="합 계산">
            </td>

        </tr>
    </table>
</body>
</html>

 

-index.html

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <title>홈 페이지</title>
</head>
<body>
    <h3>홈 페이지 환영합니다</h3>
    <table border="1" bordercolor="blue">
        <tr>
            <td>
                서적 제목
            </td>
            <td>
                <input type="text" name="title">
            </td>
        </tr>
        <tr>
            <td>
                서적 표지
            </td>
            <td>
                <input type="file" name="photo">
            </td>
        </tr>
        <tr>
            <td>
                서적 저자
            </td>
            <td>
                <input type="text" name="author">
            </td>
        </tr>
        <tr>
            <td>
                서적 출간일자
            </td>
            <td>
                <input type="text" name="created_date">
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" value="등 록">
            </td>

        </tr>
    </table>
</body>
</html>

 

- 터미널에서 web.py 실행시키면 

뒤에 /two_input치면

 


- two_input.html 

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <title>2개 값 입력</title>
</head>
<body>
<form action="/two_result" method="post">
    <table border="1" bordercolor="blue">
        <tr>
            <td>
                값1
            </td>
            <td>
                <input type="text" name="value1" placeholder="숫자입력">
            </td>
        </tr>
        <tr>
            <td>
                값2
            </td>
            <td>
                <input type="text" name="value2" placeholder="숫자입력">
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" value="합 계산">
            </td>

        </tr>
    </table>
</form>
</body>
</html>

 

-two_result.html 

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <title>2개 값 입력</title>
</head>
<body>

    <table border="1" bordercolor="blue">
        <tr>
            <td>
                값1
            </td>
            <td>
                <input type="text" name="value1" value="{{value1}}" readonly>
            </td>
        </tr>
        <tr>
            <td>
                값2
            </td>
            <td>
                <input type="text" name="value2" value="{{value2}}" readonly>
            </td>
        </tr>
        <tr>
            <td>
                합 결과
            </td>
            <td>
                <input type="text" name="result" value="{{sum}}">

            </td>
        </tr>
    </table>

</body>
</html>

 

-web.py

from flask import Flask, render_template, request

app = Flask(__name__)


@app.route("/", methods=['GET'])
def two_input():
    return render_template('two_input.html')


@app.route("/two_result", methods=['POST'])
def two_result():
    value1 = request.form.get('value1')
    value2 = request.form.get('value2')
    sum = int(value1) + int(value2)

    return render_template('two_result.html', value1=value1, value2=value2, sum=sum)


if __name__ == "__main__":
    app.run()

 


- postman download 

 

www.postman.com/downloads/

 

Download Postman | Try Postman for Free

Try Postman for free! Join 13 million developers who rely on Postman, the collaboration platform for API development. Create better APIs—faster.

www.postman.com

64-bit 클릭

- 다운받고 실행 

구글 계정으로 로그인

 

Send 클릭 

 


 

'mongodb' 카테고리의 다른 글

파이참 프로페셔널 버전  (0) 2021.01.19
몽고디비 3일차- django, 장고  (0) 2021.01.18
몽고디비 3일차- studio 3t, mongodb tool  (0) 2021.01.18
몽고디비 2일차- pymongo, Altlas  (0) 2021.01.15
몽고디비 2일차 - 크롤링  (0) 2021.01.15

+ Recent posts