Lecture 12 Revision

Transitioning to Other Web Frameworks

alt text

Model

View

Convention vs. Configuration is a design philosophy that:

Important advice:

Web frameworks come with their own conventions

CodeIgniter – Mapping a Model to a DB Table

Model Configuration: The model class provides configuration options to facilitate the smooth functioning of its methods.

just needed one file, everything else auto generated

How to transition to other web Frameworks?

posting them off, the method (POST, GET)

Codeigniter has a fully-fledged ORM

Routing

Comparing Frameworks

how does a base template look like in these frameworks

Django (Server-side Python Framework)

Creating a Django Project

Django Project Structure

The main directories are:

Creating a Model for the WIKI

In Django we don’t create the migration first.

alt text

create a class, give it it's fields, and that is your model

Autogenerated Migration

alt text

Base Templates

Base Template Section
alt text alt text

defining a block, can put the content in

Views

alt text

From urls.py

alt text

React/next.js

Using create-react-app

Comes with a command line tool

Project base folder and all the folders you need

Creating a React Project

Create a new react client side application:

alt text

alt text

Has functions returning HTML

alt text

ItemList Component

alt text

Add Item with a button

Code output
alt text alt text

codeigniter using restful API's, had to use javascript to write it to the screen

Any time anything in state changes, view will re-render

EXAM commonalities in projects

When you do the build, will output one HTML files and one JavaScript file

Next.JS

React style of code which will run on the server

JavaScript that runs on the server

Using create-next-app

alt text

Create the schema

alt text

Generate the Prisma Client

Prisma Client is an auto-generated and type-safe query builder for Node.js

Create the database table (Similar to Migrations)

Command Output (SQL)
alt text alt text

Querybuilder and

Run migrate function

Page-based Routing

alt text

normally always seen a routes file

Dynamic Page based Routing

alt text

Want ID at the end of the route to load something

Edit/something

Run Next.js Dev Server

Should run on port 3000 unless that is being used. It will then increment the port number eg 3001

alt text

load the initial page, load new and

Layout

alt text

Client-side and Server-side Code

alt text

API, edit a page or update a page

Other Frameworks

Flask

alt text