Giter Site home page Giter Site logo

app-generator / tutorial-flask-authentication Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 2 KB

Flask Authentication - Learn to code | AppSeed

Home Page: https://github.com/app-generator/tutorial-flask

License: MIT License

Python 100.00%
flask-tutorial flask-auth learn-to-code

tutorial-flask-authentication's Introduction

Flask App 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.


Topics


Questions/Spot a problem? please open a new issue.


Flask Introduction

๐Ÿ‘‰ 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.

Flask is written in Python and it does not require particular tools or libraries.

Useful Flask Resources


๐Ÿ‘† Return to top


Set up

๐Ÿ‘‰ To code a Flask application we need some tools properly set up in our workstation. Here is the recommended list:


To finish this tutorial we will work with the console (aka terminal). In Windows, we can use Powershell or the corespondent xterm for Linux. The next step is to open a terminal and check the Python installation:

$ python --version
Python 3.8.4

If the above command returns an error please double check the Python installation and get back here after to follow up the next steps.


Install Flask

Flask is basicaly a Python package and we can install it with ease via a tool shipped by Python: PIP.

$ pip install Flask

๐Ÿ‘† Return to top


Edit the code

๐Ÿ‘‰ Create a new file named hello.py in the current directory and add this code:

from flask import Flask

app = Flask(__name__)

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

This simple code snippet ( also saved here ) does the following:

  • Import Flask, the library that we've installed in the previous step
  • app object is constructed by Flask. At this point, we can use all features provided by Flask
  • define a defaut route that will return a simple Hello message when someone access our application using the browser

๐Ÿ‘† Return to top


Start the application

๐Ÿ‘‰ Flask being such a nice framework, comes with a simple server to help us check the code without being forced to install 3rd party tools. To use it and see our minimal app running in the browser, a variable must be exported in the environment that informs Flask the name of the file:

$ # Set the FLASK_APP environment variable
$ # Unix/Mac 
$ export FLASK_APP=hello.py
$
$ # Windows OS 
$ set FLASK_APP=hello.py
$ 
$ # Windows OS - Powershell
$ $env:FLASK_APP = ".\hello.py"

Once we have this variable we can call Flask:

$ flask run

By default Flask will start the application on address 'localhost:5000'. If we visit the aplication in the browser, we should see the message:

My first Flask APP!


๐Ÿ‘† Return to top


Summary

๐Ÿ‘‰ During this tutorial we've learned a few basic things:

  • What is Flask and how to install it
  • We've code a super simple app
  • We've seen the application running in the browser

Where to go from here?


๐Ÿ‘† Return to top



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

tutorial-flask-authentication's People

Contributors

app-generator avatar

Watchers

 avatar  avatar  avatar

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.