[PYTHON] Creating a simple app with flask

# Introduction We use Flask to create an application from scratch and organize it so that you can learn the necessary technology.

--Creating a simple app with flask ← ★ Currently here -Try to create a Home screen -Try to create an authentication function -Try to handle the database -Try to create CRUD function

What is Flask

Flask is a Python micro-framework developed in 2010. It is called a "micro-framework" because it relies on the minimum required libraries and does not require any specific tools or libraries.

It has the following features.

Single file framework

Flask was created with the motivation to be a "single file framework". It also has the greatness of being customizable to any application since it was a minimal yesterday.

Development environment

We recommend that you do it in a virtual environment.

Deliverables

Directory structure

app/
  ├ src/
     ├ templates
     ├ static
  ├ manage.py
  ├ requirements.txt
  ├ venv
  ├ server.py

Creating a simple app in flask

Creating a init file

from flask import Flask

app = Flask(__name__)

import src.views

Create views file

from src import app

@app.route('/')
def index():
    return "Hello World"

Creating a startup file

import sys
sys.dont_write_bytecode = True

from src import app

if __name__ == '__main__':
    host = '127.0.0.1'
    port = 5000
    app.run(host=host, port=port, debug=True)

This file describes what happens when a request is met at http://127.0.0.1:5000/. *'if name =='main':' describes what happens when this file is run directly. *'Debug = True' launches the application in debug mode and runs it to display various information on the console when the app is run.

Run

$ python3 serve.py
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

python-flask.png

Recommended Posts

Creating a simple app with flask
Create a simple web app with flask
Creating a Flask server with Docker
Creating a simple PowerPoint file with Python
How to deploy a web app made with Flask to Heroku
Creating a web application using Flask ②
Creating a decision tree with scikit-learn
Run the app with Flask + Heroku
I made a simple book application with python + Flask ~ Introduction ~
Creating a simple table using prettytable
(Failure) Deploy a web app made with Flask on heroku
Creating a web application using Flask ①
(For beginners) Try creating a simple web API with Django
Creating a web application using Flask ③
Creating a web application using Flask ④
A dentist (!?) Created a tongue coating amount judgment app with flask + keras
Python: Introduction to Flask: Creating a number identification app using MNIST
Creating and understanding a test app Ubuntu 18.04 + Nginx + Flask + Let's lencript
A simple RSS reader made with Django
Creating an image splitting app with Tkinter
Deploy flask app with mod_wsgi (using pipenv)
Play like a web app with ipywidgets
Create a simple GUI app in Python
Make a rare gacha simulator with Flask
Create a GUI app with Python's Tkinter
Daemonize a Python web app with Supervisor
Creating a login screen with Django allauth
Let's make a simple language with PLY 1
Launch a Flask app in Python Anywhere
Easy web app with Python + Flask + Heroku
Create a web service with Docker + Flask
Getting Started with Heroku, Deploying Flask App
Make a desktop app with Python with Electron
I made a simple blackjack with Python
[GCP] Procedure for creating a web application with Cloud Functions (Python + Flask)
Set up a simple HTTPS server with asyncio
[Piyopiyokai # 1] Let's play with Lambda: Creating a Lambda function
How to develop a cart app with Django
Create an image composition app with Flask + Pillow
Vienna with Python + Flask web app on Jenkins
Procedure for creating a LineBot made with Python
Start a simple Python web server with Docker
[Python] Make a simple maze game with Pyxel
I made a simple Bitcoin wallet with pycoin
A memo when creating a python environment with miniconda
Launch a web server with Python and Flask
Commands for creating a python3 environment with virtualenv
Flow of creating a virtual environment with Anaconda
How to create a multi-platform app with kivy
A simple to-do list created with Python + Django
Try creating a FizzBuzz problem with a shell program
I made a Mattermost bot with Python (+ Flask)
Build a flask app made with tensorflow and dlib to work on centos7
Accelerate a large number of simple queries with MySQL
Create a Todo app with Django REST Framework + Angular
Make a morphological analysis bot loosely with LINE + Flask
[Day 9] Creating a model
Creating a Home screen
I want to transition with a button in flask
4. Creating a structured program
A4 size with python-pptx