serin99
serin 개발 일기
serin99
전체 방문자
오늘
어제
  • 분류 전체보기 (79)
    • FE (26)
      • JavaScript (14)
      • React (7)
      • Web (5)
    • IT (24)
      • [FE] 위클리 페이퍼 (19)
      • CS (4)
    • Project (4)
    • Python (8)
    • DB (2)
    • IoT (14)
      • 라즈베리파이 (9)
      • 아두이노 (4)

태그

  • 라즈베리파이
  • 부트캠프
  • 프로그래밍
  • Python
  • 자바스크립트

인기 글

최근 글

최근 댓글

티스토리

hELLO · Designed By 정상우.
serin99
FE/Web

Flask 사용해보기 2

FE/Web

Flask 사용해보기 2

2023. 5. 9. 16:48
728x90

 

간단하게 웹 서버를 구축하기 위해 환경 구성을 위하여 세부 폴더와 소스코드를 작성한다.

 

 

<simpleweb.py>

from flask import Flask, render_template

app = Flask(__name__)
 
@app.route('/')
def index():
	return render_template('index.html')
    
@app.route('/header')
def header():
	return render_template('header.html')
    
@app.route('/link')
def link():
	return render_template('link.html')
    
@app.route('/text')
def text():
	return render_template('text.html')
    
@app.route('/list1')
def list1():
return render_template('list1.html')

@app.route('/list2')
def list2():
	return render_template('list2.html')

@app.route('/table')
def table():
	return render_template('table.html')

@app.route('/image')
def image():
	return render_template('image.html')

if __name__ == '__main__':
	app.run(debug=True, host='자신의 ip', port=5000)

 

 

<index.html>

 

<html>
<body>
Hello My Web
</body>
</html>

 

 

<header.html>

 

<html>
<head>
<title>HTML5 + CSS3 Text</title>
</head>
<body>
<h1> 1</h1>
<h2> 2</h2>
<h3> 3</h3>
<h4> 4</h4>
<h5> 5</h5>
<h6> 6</h6>
</body>
</html>

 

 

<link.html>

 

<html>
<head>
<title>HTML TEXT Basic Page</title>
</head>
<body>
<a href="http://naver.com/"> </a><br>
<a href="http://daum.net/"> </a><br>
</body>
</html>

 

 

<text.html>

 

<html>
<head>
<title>HTML TEXT Basic Page</title>
</head>
<body>
<h1><b>Lorem ipsum dolor sit amet</b></h1>
<h1><i>Lorem ipsum dolor sit amet</i></h1>
<h1><small>Lorem ipsum dolor sit amet</small></h1>
<h1>Lorem ipsum dolor <sub> sit amet</sub></h1>
<h1>Lorem ipsum dolor <sup> sit amet</sup></h1>
<h1><ins>Lorem ipsum dolor sit amet</ins></h1>
<h1><del>Lorem ipsum dolor sit amet</del></h1>
<hr>
<b>Lorem ipsum dolor sit amet</b><br>
<i>Lorem ipsum dolor sit amet</i><br>
<small>Lorem ipsum dolor sit amet</small><br>
Lorem ipsum dolor <sub> sit amet</sub><br>
Lorem ipsum dolor <sup> sit amet</sup><br>
<ins>Lorem ipsum dolor sit amet</ins><br>
<del>Lorem ipsum dolor sit amet</del><br>
</body>
</html>

 

 

<list1.html>

 

<html>
<head>
<title>HTML List Basic Page</title>
</head>
<body>
<ul>
    <li>사과</li>
    <li>바나나</li>
    <li>오렌지</li>
</ui>
</body>
</html>

 

 

<list2.html>

 

<html>
<head>
<title>HTML List Basic Page</title>
</head>
<body>
<ol>
   <li>사과</li>
   <li>바나나</li>
   <li>오렌지</li>
</ol>
</body>
</html>

 

 

<table.html>

 

<html>
<head>
<title>HTML Table Basic Page</title>
</head>
<body>
<table border="1">
<thead>
	<tr>
		<th>월</th>
		<th>화</th>
		<th>수</th>
		<th>목</th>
		<th>금</th>
	</tr>
</thead>
<tbody>
	<tr>
		<td>1교시</td>
		<td>영어</td>
		<td>국어</td>
		<td>과학</td>
		<td>미술</td>
		<td>기술</td>
	</tr>
	<tr>
		<td>2교시</td>
		<td>도덕</td>
		<td>체육</td>
		<td>영어</td>
		<td>수학</td>
		<td>사회</td>
	</tr>
</tbody>
</table>
</body>
</html>

 

python\simpleweb
python simpleweb.py

터미널에서 위와 같이 명령어를 입력하여 프로그램을 실행한다.

 

위와 같이 서버가 시작된 것을 확인한다.

728x90

'FE > Web' 카테고리의 다른 글

Web 기초 지식  (0) 2023.06.30
챗 GPT로 웹 페이지 만들기  (0) 2023.06.16
Flask 사용해보기  (0) 2023.05.09
DB 데이터 웹 페이지로 출력하기(라즈베리파이, PHP)  (0) 2023.03.02
    'FE/Web' 카테고리의 다른 글
    • Web 기초 지식
    • 챗 GPT로 웹 페이지 만들기
    • Flask 사용해보기
    • DB 데이터 웹 페이지로 출력하기(라즈베리파이, PHP)
    serin99
    serin99
    FE 개발자가 되기 위해 공부하는 사람

    티스토리툴바

    단축키

    내 블로그

    내 블로그 - 관리자 홈 전환
    Q
    Q
    새 글 쓰기
    W
    W

    블로그 게시글

    글 수정 (권한 있는 경우)
    E
    E
    댓글 영역으로 이동
    C
    C

    모든 영역

    이 페이지의 URL 복사
    S
    S
    맨 위로 이동
    T
    T
    티스토리 홈 이동
    H
    H
    단축키 안내
    Shift + /
    ⇧ + /

    * 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.