Program In Flask
Install Flask and create simple “Hello World”application
1- Hello World program
For create “Hello world” program follow the below steps:
- Create two folder one “development”and inside “flask”folder.
- Open your “command prompt”.
- Give command: cd development.
- Give command: cd flask.
- Create virtualenv “venv” name.
- Give command : virtualenv venv.
- Activate virtualenv.
- Give command : dir
- Give command: “venv\scripts\activate”(virtualenv activate).
- Give command: python(check its working).
- Give command: exit.
- Install Flask: pip install flask.
- Download subline any one like :-visualstudio.
- After that open your “development” folder in visual studio.
- create a file “class.py” in subline.
- Run “class.py” in command prompt
- Give command: ls(it shows all the file in flask folder)
- Give command : python class.py
Working with model views templates:
MVC and MVT
Model – Model represents an object or JAVA POJO carrying data. It can also have logic to update controller if its data changes. View – View represents the visualization of the data that model contains. Controller – Controller acts on both model and view. It controls the data flow into model object and updates the view whenever data changes. It keeps view and model separate.
The MVT (Model View Template) is a software design pattern. It is a collection of three important components’ Model’ ‘ View’ and ‘Template’. The Model helps to handle database. It is a data access layer which handles the data. The Template is a presentation layer which handles User Interface part completely. The View is used to execute the business logic and interact with a model to carry data and renders a template.