Giter Club home page Giter Club logo

tutorial-flask's Introduction

Flask Tutorial

Content provided by experienced developers based on the suggestions/questions from the audience. This initiative aims to provide Free/Allways up-to-date programming tutorials - Read the Manifest.


How it works

  • Access the existing content
  • Open a new issue to get an answer related to an existing topic
  • Open a new issue to open a new tutorial topic
  • Answers will be provided by experienced contributors
  • For Support chat with AppSeed team

Topics


What is Flask

๐Ÿ‘‰ Flask is a lightweight web application framework. It is designed to make getting started quick and easy, with the ability to scale up to complex applications. Compared to Django, Flask provides a lightweight codebase and more freedom to the developer.


๐Ÿ‘† Return to top


Install Flask

๐Ÿ‘‰ The easiest way to install Flask is to use PIP the official package-management tool.

$ pip install Flask

How to check Flask version

Open a Python console (type python in terminal) and check the installed version as below:

>> import flask
>> flask.__version__
'1.1.2' 
>>>

In this case the installed version is 1.1.2


๐Ÿ‘† Return to top


A minimal App

๐Ÿ‘‰ Open a terminal and install Flask (if not already installed) using PIP:

$ pip install Flask

Use your preferred editor to create a file called hello.py with this content:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return f'My first Flask!'

Save the file and start the app:


$ env FLASK_APP=hello.py flask run
 * Serving Flask app "hello"
 * Running on http://127.0.0.1:5000/

Above commnand does two things:

  • Set the FLASK_APP variable (required by Flask)
  • Execute our code with flask run command

By visiting the app in the browser localhost:5000 we should see My first Flask! message.


๐Ÿ‘† Return to top


๐Ÿ‘‰ Being such a lightweight framework, Flask comes with great flexibility regarding the codebase structure of a project. We can use a single file and drop all the code or split the app logic in more files and directories. All variants works but we migth have issues once our project is getting bigger and migth become unreadable for others.

Well, this section presents a few options to keep in mind when we start a Flask project.


๐Ÿ”— Read more: Flask Project Structure: Single File, Isolated App, Blueprints


๐Ÿ‘† Return to top


๐Ÿ‘‰ We can use the information learned in the previous sections and build from scratch a simple Flask project on top of a modern Bootstrap UI Kit.


๐Ÿ”— Read more: Flask Bootstrap Sample


๐Ÿ‘† Return to top


๐Ÿ‘‰ Jinja is a modern and designer-friendly templating language for Python, modelled after Django's templates. It is a text-based template language and thus can be used to generate any markup as well as source code.


๐Ÿ”— Read more: Jinja Template


๐Ÿ‘† Return to top



Flask Tutorial - Free/Allways up-to-date Flask-related content | by AppSeed.

tutorial-flask's People

Contributors

app-generator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tutorial-flask's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.