Flask Overview
Flask is the micro-framework Python: the routing (the 1 line, the view), the render (the Jinja2, the template), and the no is the batteries (the ORM, the admin, the form, the extension the add). The micro is the core (the 1 file, the no the opinion), the extension is the 1 the no (the SQLAlchemy, the Login, the WTF), and the WSGI is the server (the gunicorn, the no the dev). This chapter covers what Flask is (the routing, the render, the no), the extension (the 1, the no), the WSGI (the gunicorn, the no the dev), and the microblog the running example the chapters build on.
The micro: The core
# the MICRO (the core, the 1 file,
# the no opinion, the no the 1):
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def index():
return render_template(
"index.html",
title="the 1")
# the 2: the route (the path,
# the view, the no the 1)
# the 3: the render (the template,
# the context, the no the 1)
# the no: the 1 (the 1, the
# the 1, the no the 1)
# the 1 (the app, the 1, the
# no the 1):
# the no: the 1 (the no,
# the no, the no
# the no, the no
# the no):
if __name__ == "__main__":
app.run(debug=True)
# the 127.0.0.1:5000 (the dev,
# the no the prod, the no
# the 1)
# the no: the no (the no,
# the no, the no
# the no, the no
# the no)
# the NO (the batteries, the
# extension, the 1 the no):
# the no: the 1 (the no,
# the no, the no
# the no, the no
# the no):
# the no: the no (the no,
# the no, the no
# the no, the no
# the no)
The micro is the core: the 1 file (the app.py, the 1 the app), the no is the opinion (the folder, the DB, the form, the 1 the the), and the 1 is the 1 (the no the 1, the no the the) - the app = Flask(__name__) is the 1 (the 1, the no the 1, the no the the), and the @app.route is the 1 (the path, the view, the no the 1). The no is the batteries: the ORM (the SQLAlchemy, the 1 the the), the admin (the no, the 1 the the), the form (the WTF, the 1 the the), and the auth (the Login, the 1 the the) - the extension is the 1 the no: the 1 is the no (the 1, the no the 1), and the 1 is the no (the no the 1, the no the the) - the WSGI is the next: the gunicorn the no the dev.
The WSGI and the microblog
# the WSGI (the gunicorn, the no
# dev, the no the 1):
# the no: the 1 (the no,
# the no, the no
# the no, the no
# the no):
pip install gunicorn
# the no: the 2 (the no,
# the no, the no
# the no, the no
# the no):
gunicorn "app:create_app()" \
--workers 4 \
--bind 127.0.0.1:8000
# the no: the no (the no,
# the no, the no
# the no, the no
# the no)
# the no: the no (the no,
# the no, the no
# the no, the no
# the no)
# the MICROBLOG (the running
# example, the 20 chapter,
# the no the 1):
# the no: the 1 (the no,
# the no, the no
# the no, the no
# the no):
# the 1: the User (the no,
# the no, the no
# the no, the no
# the no)
# the 2: the Post (the no,
# the no, the no
# the no, the no
# the no)
# the 3: the 1 (the no,
# the no, the no
# the no, the no
# the no)
# the 4: the 1 (the no,
# the no, the no
# the no, the no
# the no)
The WSGI is the gunicorn: the no is the dev (the 1, the no the 1), the 4 worker is the 1 (the CPU, the no the 1), and the bind is the 127.0.0.1 (the nginx, the no the public) - the app.run is the dev (the auto-reload, the 1, the no the the), and the create_app is the factory (the blueprint chapter, the no the 1). The microblog is the 1 the 20 the chapter: the User is the 1 (the username, the password, the no the 1), the Post is the 1 (the body, the user, the no the 1), the 1 is the no (the 1, the no the 1), and the 1 is the no (the 1, the no the 1) - the rule is the one: the micro is the core, the extension is the 1, and the WSGI is the no the dev - the next chapter's install is the venv the pip the 1 the app the run.
The Working Rules
- The micro is the core, the 1 file. The app.py the 1 (the app, the no the 1), and the no is the opinion (the folder, the DB, the form, the 1 the the) - the Flask(__name__) the 1 (the no the 1), and the @app.route the 1 (the path, the view, the no the 1).
- The no is the batteries, the extension the 1. The ORM the SQLAlchemy (the 1 the the), and the form the WTF (the 1 the the) - the auth the Login (the 1 the the), and the 1 the no (the 1, the no the 1, the no the the).
- The WSGI is the gunicorn, the no dev. The 4 the worker (the CPU, the no the 1), and the bind the 127.0.0.1 (the nginx, the no the public) - the app.run the dev (the auto-reload, the 1, the no the the), and the create_app the factory (the blueprint, the no the 1).
- The microblog is the 1, the 20 the chapter. The User the 1 (the username, the password), and the Post the 1 (the body, the user) - the 1 the no (the 1, the no the 1), and the 1 the no (the 1, the no the 1).
Summary
Flask is the micro-framework Python: the micro is the core (the 1 file, the no the opinion, the Flask(__name__) the 1, the @app.route the 1), the no is the batteries (the ORM the SQLAlchemy, the admin the no, the form the WTF, and the auth the Login), the extension is the 1 the no (the 1, the no the 1), and the WSGI is the gunicorn (the 4 the worker, the 127.0.0.1, the no the dev, the app.run the auto-reload). The microblog is the running example (the User the username, the Post the body, the 1 the no, the 1 the no) - the rule is the one: the micro the core, the extension the 1, and the WSGI the no the dev. The next chapter's install is the venv: the python3 -m venv the 1, the pip install flask the 1, and the app.run the 127.0.0.1:5000 the dev.