サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
ブラックフライデー
flask.palletsprojects.com
Warning: This is an old version. The latest stable version is Version 2.1.x. Welcome to Flask¶ Welcome to Flask’s documentation. Get started with Installation and then get an overview with the Quickstart. There is also a more detailed Tutorial that shows how to create a small but complete application with Flask. Common patterns are described in the Patterns for Flask section. The rest of the docs
Configuration Handling¶ Applications need some kind of configuration. There are different settings you might want to change depending on the application environment like toggling the debug mode, setting the secret key, and other such environment-specific things. The way Flask is designed usually requires the configuration to be available when the application starts up. You can hard code the config
Quickstart¶ Eager to get started? This page gives a good introduction to Flask. Follow Installation to set up a project and install Flask first. A Minimal Application¶ A minimal Flask application looks something like this: from flask import Flask app = Flask(__name__) @app.route("/") def hello_world(): return "<p>Hello, World!</p>" So what did that code do? First we imported the Flask class. An in
API¶ This part of the documentation covers all the interfaces of Flask. For parts where Flask depends on external libraries, we document the most important right here and provide links to the canonical documentation. Application Object¶ class flask.Flask(import_name, static_url_path=None, static_folder='static', static_host=None, host_matching=False, subdomain_matching=False, template_folder='temp
Uploading Files¶ Ah yes, the good old problem of file uploads. The basic idea of file uploads is actually quite simple. It basically works like this: A <form> tag is marked with enctype=multipart/form-data and an <input type=file> is placed in that form. The application accesses the file from the files dictionary on the request object. use the save() method of the file to save the file permanently
Flask uses a concept of blueprints for making application components and supporting common patterns within an application or across applications. Blueprints can greatly simplify how large applications work and provide a central means for Flask extensions to register operations on applications. A Blueprint object works similarly to a Flask application object, but it is not actually an application.
Background Tasks with Celery¶ If your application has a long running task, such as processing some uploaded data or sending email, you don’t want to wait for it to finish during a request. Instead, use a task queue to send the necessary data to another process that will run the task in the background while the request returns immediately. Celery is a powerful task queue that can be used for simple
Caching¶ When your application runs slow, throw some caches in. Well, at least it’s the easiest way to speed up things. What does a cache do? Say you have a function that takes some time to complete but the results would still be good enough if they were 5 minutes old. So then the idea is that you actually put the result of that calculation into a cache for some time. Flask itself does not provide
SQLAlchemy in Flask¶ Many people prefer SQLAlchemy for database access. In this case it’s encouraged to use a package instead of a module for your flask application and drop the models into a separate module (Large Applications as Packages). While that is not necessary, it makes a lot of sense. There are four very common ways to use SQLAlchemy. I will outline each of them here: Flask-SQLAlchemy Ex
uWSGI¶ uWSGI is a fast, compiled server suite with extensive configuration and capabilities beyond a basic server. It can be very performant due to being a compiled program. It is complex to configure beyond the basic application, and has so many options that it can be difficult for beginners to understand. It does not support Windows (but does run on WSL). It requires a compiler to install in som
Deploying with Fabric¶ Fabric is a tool for Python similar to Makefiles but with the ability to execute commands on a remote server. In combination with a properly set up Python package (Large Applications as Packages) and a good concept for configurations (Configuration Handling) it is very easy to deploy Flask applications to external servers. Before we get started, here a quick checklist of thi
Navigation index modules | Flask Documentation (3.1.x) » AJAX with jQuery AJAX with jQuery¶ Obsolete, see JavaScript, fetch, and JSON instead. Navigation Overview Quick search © Copyright 2010 Pallets. Created using Sphinx 8.2.3.
Security Considerations¶ Web applications usually face all kinds of security problems and it’s very hard to get everything right. Flask tries to solve a few of these things for you, but there are a couple more you have to take care of yourself. Cross-Site Scripting (XSS)¶ Cross site scripting is the concept of injecting arbitrary HTML (and with it JavaScript) into the context of a website. To reme
MongoDB with MongoKit¶ MongoKit is no longer maintained. See MongoDB with MongoEngine instead.
Extensions¶ Extensions are extra packages that add functionality to a Flask application. For example, an extension might add support for sending email or connecting to a database. Some extensions add entire new frameworks to help build certain types of applications, like a REST API. Finding Extensions¶ Flask extensions are usually named “Flask-Foo” or “Foo-Flask”. You can search PyPI for packages
Templates¶ Flask leverages Jinja as its template engine. You are obviously free to use a different template engine, but you still have to install Jinja to run Flask itself. This requirement is necessary to enable rich extensions. An extension can depend on Jinja being present. This section only gives a very quick introduction into how Jinja is integrated into Flask. If you want information on the
Patterns for Flask¶ Certain features and interactions are common enough that you will find them in most web applications. For example, many applications use a relational database and user authentication. They will open a database connection at the beginning of the request and get the information for the logged in user. At the end of the request, the database connection is closed. These types of pa
Testing Flask Applications¶ Flask provides utilities for testing an application. This documentation goes over techniques for working with different parts of the application in tests. We will use the pytest framework to set up and run our tests. The tutorial goes over how to write tests for 100% coverage of the sample Flaskr blog application. See the tutorial on tests for a detailed explanation of
Welcome to Flask¶ Welcome to Flask’s documentation. Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy, with the ability to scale up to complex applications. Get started with Installation and then get an overview with the Quickstart. There is also a more detailed Tutorial that shows how to create a small but complete application with Flask.
このページを最初にブックマークしてみませんか?
『Welcome | Flask (A Python Microframework)』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く