기본 콘텐츠로 건너뛰기

[Python, Flask] Flask 처음 시작해보기

[Python, Flask] Flask 처음 시작해보기

[Python, Flask] Flask 처음 시작해보기

from flask import Flask app = Flask(__name__)

@app.route( '/' ) def hello_world(): return 'Hello, World!'

@app.route( '/user/' ) def show_user_profile(username): # show the user profile for that user return 'User %s' % username

@app.route( '/post/' ) def show_post(post_id): # show the post with the given id, the id is an integer return 'Post %d' % post_id

@app.route( '/path/' ) def show_subpath(subpath): # show the subpath after /path/ return 'Subpath %s' % subpath

PS \python\flask> set FLASK_APP=flask_exam01.py

PS \python\flask> $env:FLASK_APP = 'flask_exam01.py'

PS \python\flask> set FLASK_ENV=development

PS \python\flask> flask run

* Serving Flask app "flask_exam01.py"

* Environment: production

WARNING: Do not use the development server in a production environment.

Use a production WSGI server instead.

* Debug mode: off

* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

-> 브라우저를 띄워서 아래 URL로 테스트를 해보면 간단하게 결과를 알수 있다.

http://localhost:5000/

http://localhost:5000/user/kim

http://localhost:5000/post/1234

http://localhost:5000/path/test/sd/f/d

Converter types:

string (default) accepts any text without a slash int accepts positive integers float accepts positive floating point values path like string but also accepts slashes uuid accepts UUID strings

from http://fenderist.tistory.com/99 by ccl(A) rewrite - 2020-03-06 10:20:19

댓글

이 블로그의 인기 게시물

Flask 13. pythonanywhere에 배포하기

Flask 13. pythonanywhere에 배포하기 Login: PythonAnywhere It's always a pleasure to hear from you! Ask us a question, or tell us what you love or hate about PythonAnywhere. We'll get back to you over email ASAP. Sorry, there was an error connecting to the server. Please try again in a few moments... www.pythonanywhere.com from http://ohdowon064.tistory.com/124 by ccl(A) rewrite - 2020-03-11 15:54:10

2020년의 웹 기술 개발 스택

2020년의 웹 기술 개발 스택 웹 응용 프로그램을 개발할 때 고려해야 할 가장 중요한 것은 앱의 기반이 되는 기술 스택이다. 적절한 기술 스택을 통해 적은 예산으로 가장 큰 효과를 제공하는 것은 기업 입장에서는 특히 어려운 과제이며 올바른 기술 스택 사용은 프로젝트의 성공과 실패를 결정짓는 중요한 열쇠다. 물론 필자는 프로젝트를 직접 운영하고 있지도 않고, 사용할 기술 스택을 선택할 입장이 아니기 때문에 해당 사항이 없다. 하지만 2020년을 살아가는 Front-End 개발자로서 쌓아나가야 할 기술 스택의 방향성을 정하는 데 도움이 되고자 포스팅을 해본다. 2020년 웹 기술 개발 스택 최신 웹 기술 스택을 선택하기 이전에 웹 응용 프로그램 개발 프로세스 구성요소를 명확하게 이해해야 한다. 웹 개발에는 크게 클라이언트 쪽과 서버 쪽의 두 가지로 나뉜다. 클라이언트 측 프로그래밍 (Front-End) 웹 개발에는 사용자가 화면에서 보는 모든 것이 포함된다. 주요 프론트엔드 기술 스택 구성 요소는 다음과 같다. HTML (Hyper Markup Language) 및 CSS (Cascading Style Sheets) HTML은 브라우저에게 웹 페이지의 내용을 표시하는 방법을 알려준다. CSS는 그 내용을 스타일링 한다. (+) Bootstrap : HTML, CSS 관리에 유용한 프레임워크 JavaScript (JS) 웹 페이지를 대화식으로 만든다. 더 빠르고 쉬운 웹 개발을 위한 많은 JS 라이브러리와 프레임워크가 있다. - 라이브러리 : jQuery, React.js 및 Zepto.js - 프레임워크 : Angular, Vue, Backbone 및 Ember) 서버 측 프로그래밍 (Back-End) 서버 측은 어플리케이션(Back-End), 데이터베이스 및 서버 자체가 포함된다. 사용자에게 보이지 않지만 발전소가 집에 전기를 생성하는 것처럼 클라이언트 측에 전원을 공급하는 역할을 한다. 문제는 주로 웹 응용 프로그...