///
Search
⛸️

01. Introduce

플라스크는 프레임 워크이다.
프레임워크란 자주 사용되는 코드를 체계화하여 쉽게 사용할 수 있도록 도와주는 코드 집합
라이브러리와 혼동될 수 있지만 좀 더 규모가 크고 프로젝트의 기반이 됨
건축에 비유하면 구조를 만드는 골조가 프레임 워크 그외 자재들이 라이브러리

플라스크 사이트

Python Version

We recommend using the latest version of Python 3. Flask supports Python 3.5 and newer, Python 2.7, and PyPy.

Dependencies

These distributions will be installed automatically when installing Flask.
Werkzeug implements WSGI, the standard Python interface between applications and servers.
Jinja is a template language that renders the pages your application serves.
MarkupSafe comes with Jinja. It escapes untrusted input when rendering templates to avoid injection attacks.
ItsDangerous securely signs data to ensure its integrity. This is used to protect Flask’s session cookie.
Click is a framework for writing command line applications. It provides the flask command and allows adding custom management commands.

Optional dependencies

These distributions will not be installed automatically. Flask will detect and use them if you install them.
Blinker provides support for Signals.
SimpleJSON is a fast JSON implementation that is compatible with Python’s json module. It is preferred for JSON operations if it is installed.
python-dotenv enables support for Environment Variables From dotenv when running flask commands.
Watchdog provides a faster, more efficient reloader for the development server.

Virtual environments

Use a virtual environment to manage the dependencies for your project, both in development and in production.
What problem does a virtual environment solve? The more Python projects you have, the more likely it is that you need to work with different versions of Python libraries, or even Python itself. Newer versions of libraries for one project can break compatibility in another project.
Virtual environments are independent groups of Python libraries, one for each project. Packages installed for one project will not affect other projects or the operating system’s packages.
Python 3 comes bundled with the venv module to create virtual environments. If you’re using a modern version of Python, you can continue on to the next section.
If you’re using Python 2, see Install virtualenv first.

Create an environment

Create a project folder and a venv folder within:
$ mkdir myproject $ cd myproject $ python3 -m venv venv
On Windows:
$ py -3 -m venv venv
If you needed to install virtualenv because you are using Python 2, use the following command instead:
$ python2 -m virtualenv venv
On Windows:
> \Python27\Scripts\virtualenv.exe venv

Activate the environment

Before you work on your project, activate the corresponding environment:
$ . venv/bin/activate
On Windows:
> venv\Scripts\activate
Your shell prompt will change to show the name of the activated environment.

Install Flask

Within the activated environment, use the following command to install Flask:
$ pip install Flask
Flask is now installed. Check out the Quickstart or go to the Documentation Overview.

Living on the edge

If you want to work with the latest Flask code before it’s released, install or update the code from the master branch:
$ pip install -U https://github.com/pallets/flask/archive/master.tar.gz

Install virtualenv

If you are using Python 2, the venv module is not available. Instead, install virtualenv.
On Linux, virtualenv is provided by your package manager:
# Debian, Ubuntu $ sudo apt-get install python-virtualenv # CentOS, Fedora $ sudo yum install python-virtualenv # Arch $ sudo pacman -S python-virtualenv
If you are on Mac OS X or Windows, download get-pip.py, then:
$ sudo python2 Downloads/get-pip.py $ sudo python2 -m pip install virtualenv
On Windows, as an administrator:
> \Python27\python.exe Downloads\get-pip.py > \Python27\python.exe -m pip install virtualenv

Foreword

Read this before you get started with Flask. This hopefully answers some questions about the purpose and goals of the project, and when you should or should not be using it.

What does “micro” mean?

“Micro” does not mean that your whole web application has to fit into a single Python file (although it certainly can), nor does it mean that Flask is lacking in functionality. The “micro” in microframework means Flask aims to keep the core simple but extensible. Flask won’t make many decisions for you, such as what database to use. Those decisions that it does make, such as what templating engine to use, are easy to change. Everything else is up to you, so that Flask can be everything you need and nothing you don’t.
By default, Flask does not include a database abstraction layer, form validation or anything else where different libraries already exist that can handle that. Instead, Flask supports extensions to add such functionality to your application as if it was implemented in Flask itself. Numerous extensions provide database integration, form validation, upload handling, various open authentication technologies, and more. Flask may be “micro”, but it’s ready for production use on a variety of needs.

Configuration and Conventions

Flask has many configuration values, with sensible defaults, and a few conventions when getting started. By convention, templates and static files are stored in subdirectories within the application’s Python source tree, with the names templates and static respectively. While this can be changed, you usually don’t have to, especially when getting started.
출처