Flask Tutorial 2

woody·2019년 11월 26일
0
post-thumbnail

https://flask.palletsprojects.com/en/1.1.x/

Project Layout

$ mkdir flask-tutorial
$ cd flask-tutorial

Create an environment

$ python3 -m venv venv

Activate the environment

$ . venv/bin/activate

Install Flask

$ pip install Flask

hello.py

from flask import Flask

app = Flask(__name__)


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

파이썬 프로젝트는 패키지 를 사용 하여 코드를 여러 모듈로 구성하여 필요한 곳에서 가져올 수 있으며 튜토리얼도이 작업을 수행합니다.

  • flaskr/, 애플리케이션 코드 및 파일을 포함하는 Python 패키지.
  • tests/테스트 모듈이 포함 된 디렉토리입니다.
  • venv/Flask 및 기타 종속성이 설치된 Python 가상 환경
  • Python에게 프로젝트 설치 방법을 알려주는 설치 파일.
  • 같은 버전 관리 설정, 자식 . 크기에 관계없이 모든 프로젝트에 대해 일부 유형의 버전 제어를 사용하는 습관을들이십시오.
  • 나중에 추가 할 수있는 다른 프로젝트 파일
flask-tutorial
├── flaskr/
│   ├── __init__.py
│   ├── db.py
│   ├── schema.sql
│   ├── auth.py
│   ├── blog.py
│   ├── templates/
│   │   ├── base.html
│   │   ├── auth/
│   │   │   ├── login.html
│   │   │   └── register.html
│   │   └── blog/
│   │       ├── create.html
│   │       ├── index.html
│   │       └── update.html
│   └── static/
│       └── style.css
├── tests/
│   ├── conftest.py
│   ├── data.sql
│   ├── test_factory.py
│   ├── test_db.py
│   ├── test_auth.py
│   └── test_blog.py
├── venv/
├── setup.py
└── MANIFEST.in

.gitignore

venv/

*.pyc
__pycache__/

instance/

.pytest_cache/
.coverage
htmlcov/

dist/
build/
*.egg-info/

0개의 댓글