Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 항해99솔직후기 #항해99 #부트캠프추천
- #내일배움단 #코딩프로젝트 #국비지원 #내일배움카드 #스파르타코딩클럽
- 부트스트랩 #Bootstrap #웹개발첫걸음 #스파르타코딩클럽
- 스파르타코딩클럽 #크롤링 #스크래핑
- 스파르타코딩클럽 #코딩 #jQuery #Ajax
Archives
- Today
- Total
이모저모
flask - 기본 routings 본문
# this is "__init__.py"
from flask import Flask
db = "database"
def create_app():
print("run:create_app()")
app = Flask(__name__)
@app.route('/')
def index():
return "hello"
'''routing practice'''
''' === Routing Practice === '''
from flask import jsonify, redirect, url_for
from markupsafe import escape
@app.route('/test/name/<name>')
def name(name):
return f'Name is {name}, {escape(type(name))}'
@app.route('/test/id/<int:id>')
def id(id):
return 'Id: %d' % id
@app.route('/test/path/<path:subpath>')
def path(subpath):
return subpath
@app.route('/test/json')
def json():
return jsonify({'hello': 'world'})
@app.route('/test/redirect/<path:subpath>')
def redirect_url(subpath):
return redirect(subpath)
@app.route('/test/urlfor/<path:subpath>')
def urlfor(subpath):
return redirect(url_for('path', subpath=subpath))
return app
* export FLASK_APP=<폴더..?>
* "flask run --debugger"
or
* export FLASK_APP=<폴더..?> FLASK_ENV=development
* flask run
'coding' 카테고리의 다른 글
python - flask에서 app.config['SEND_FILE_MAX_AGE_DEFAULT'] (0) | 2022.01.05 |
---|---|
flask request _ hook, application context (0) | 2022.01.04 |
'빡코'팀프로젝트 2탄 - 개발일지 (2) (0) | 2021.10.28 |
'빡코' 팀프로젝트 - 개발일지 (2) (0) | 2021.10.09 |
'빡코' 팀프로젝트 - 개발일지 (1) (0) | 2021.10.05 |
Comments