Skip to content

Instantly share code, notes, and snippets.

View haraonline's full-sized avatar
🎯
Focusing

Hara haraonline

🎯
Focusing
  • Germany
View GitHub Profile
# HTML FOR SECTION 7: LECTURE 30 - SESSION OBJECT
# USE WITH THE PYTHON FILE PROVIDED
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>session info</title>
</head>
<body>
# PYTHON CODE FOR SECTION 7: LECTURE 30 - SESSION OBJECT
# USE WITH THE HTML FILE PROVIDED
# SEE CODE IN LINE 127
from flask import Flask, render_template, request, session, g
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
app = Flask(__name__)
app.config.update(
# INCREMENTAL PYTHON CODE - REMOVED ID ATTRIBUTE FROM THE __INIT__() & __REPR__() METHODS contd.,
# OF THE PUBLICATION TABLE TO ENABLE AUTO-POPULATION
# SECTION 5: LECTURE: 23
from flask import Flask, render_template, request
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
app = Flask(__name__)
app.config.update(
# INCREMENTAL PYTHON CODE FOR CREATING BOOK TABLE
# SECTION 5: LECTURE: 22
from flask import Flask, render_template, request
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
app = Flask(__name__)
app.config.update(
# INCREMENTAL PYTHON CODE FOR CREATING PUBLICATION TABLE
# SECTION 4: LECTURE: 20
# ENTER YOUR OWN VALUE IF NEEDED FOR THE SECRET_KEY VARIABLE
# ENTER YOU OWN PASSWORD FOR THE DATABASE_URI
from flask import Flask, render_template, request
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
# python code for SECTION 3: LECTURE 16
# JINJA2 - MACROS
@app.route('/macros')
def jinja_macros():
movies_dict = {'autopsy of jane doe': 02.14,
'neon demon': 3.20,
'ghost in a shell': 1.50,
'kong: skull island': 3.50,
'john wick 2': 02.52,
<!-- SECTION 3: LECTURE 16 -->
{% macro render_dict(dictionary) %}
<table>
<tr>
<th>name</th>
<th>value</th>
<th>comments</th>
<!-- SECTION 3: LECTURE 16 -->
{% import 'macros.html' as my_macros %}
<html>
<head>
<meta charset="UTF-8">
<title>dictionary data displayed</title>
</head>
# incremental code - jinja2 filters
# SECTION 3: LECTURE 15
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/index')
@app.route('/')
<!-- HTML FOR - JINJA2 FILTERS -->
<!-- SECTION 3: LECTURE 15 -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Data Filters</title>
</head>