Upstage AI Lab 2기
2023년 12월 22일 (금) Day_010
Day_010 실시간 강의 (오전) :
파이썬 AI/데이터분석 과정 (패스트캠퍼스 김인섭 강사님)
cmd 창에서 >python app.py 로 실행
기본 format
from flask import Flask, render_template, jsonify
app = Flask(__name__)
@app.route('/')
#def function():
# return render_template('index.html', feeds=data['feeds'])
if __name__ == '__main__':
app.run(debug=True)
from flask import Flask, render_template, jsonify
app = Flask(__name__)
@app.route('/')
def main():
return "<h1>Welcome Flask!</h1>"
# @app.route('/about')
# def about():
# return "<h1>This is About page</h1>"
@app.route('/about/<user_name>')
def about(user_name):
return f"<h1>This is page about {user_name}!!!</h1>"
@app.route('/api/v1/feeds')
def all_feeds():
data = {
'feeds' : [
{'title': 'test title1', 'content': 'test content1'},
{'title': 'test title2', 'content': 'test content2'},
{'title': 'test title3', 'content': 'test content3'},
{'title': 'test title4', 'content': 'test content4'}
]
}
# return jsonify(data)
return render_template('index.html', feeds=data['feeds'])
if __name__ == '__main__':
app.run(debug=True)
'Upstage AI Lab 2기' 카테고리의 다른 글
Upstage AI Lab 2기 [Day012] (2) pandas_기초_1 (0) | 2023.12.28 |
---|---|
Upstage AI Lab 2기 [Day012] (1) numpy_기초 (0) | 2023.12.27 |
Upstage AI Lab 2기 [Day008] (2) 실습 (0) | 2023.12.22 |
Upstage AI Lab 2기 [Day008] Python project(day2) (작성) (0) | 2023.12.20 |
Upstage AI Lab 2기 [Day005] 파이썬 AI/데이터 분석 과정 part2. 크롤링 실습 (0) | 2023.12.18 |