Posts

Showing posts with the label Python

Django Cheatsheet

Image
What is Django? Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source. It is used for rapid development of web based application. Advantages : 1. Django was designed to help developers take applications from concept to completion as quickly as possible. 2. Django takes security seriously and helps developers avoid many common security mistakes. 3. Some of the busiest sites on the web leverage Django’s ability to quickly and flexibly scale. Installing Django + Setup pip install django Creating a project The below command creates a new project django-admin startproject projectName Starting a server The below command starts the development server. python manage.py runserver Django MVT Django follows MVT(Model, View, Template) architectur...

Flask Cheatsheet

Image
What is Flask Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions. Importing Flask from flask import Flask Most used import functions These are some of the most used import functions from flask import Flask, render_template, redirect, url_for, request Boilerplate This is the basic template or barebone structure of Flask. from flask import Flask app = Flask(__name__) @app.route("/") def hello_world(): return "<p>Hello, World!</p>" app.run() route(endpoint) This is to make different endpoints in our flask app. @app.route("/") Route method Allowing get and post requests on an endpoint. methods = ['GET', 'POST'] Re-run while coding This is used to automatically rerun the pr...

Python Cheatsheet

Image
What is Python? Python is an interpreted high-level general-purpose programming language. Its design philosophy emphasizes code readability with its use of significant indentation. Its language constructs as well as its object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects. Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including structured (particularly, procedural), object-oriented and functional programming. It is often described as a "batteries included" language due to its comprehensive standard library. Guido van Rossum began working on Python in the late 1980s, as a successor to the ABC programming language, and first released it in 1991 as Python 0.9.0. Python 2.0 was released in 2000 and introduced new features, such as list comprehensions and a cycle-detecting garbage collection system (in addition to reference counting). Python 3.0 was released in 2008 and was ...