SlideShare a Scribd company logo
UNTANGLING THE WEB
WEEK 10 – SERVERS AND DATABASES, OH MY
AGENDA
• Server setup – a runthrough of the whole process
• Databases
• EJS and html templates
• Local build environments
• Homework
HOMEWORK 8 REVIEW
• Some folks are having a hard time with this one
• I am not looking for the database to populate the map markers,
but only the UI to do so
• Ignore the problem of when you refresh the page the database
markers do not appear
• I suggest working on everything but the map first
NEW SERVER FOR THE THIRD PROJECT
• The cspubl server you have been using has been great. The
webserver serves your page and you don’t need to sorry about
it.
• Now we want a server, though, so I’ve stood up a new machine.
This is on Digital Ocean (if we have time we’ll talk about that
process)
• You’ll need to log onto that machine using the same type of
SSH approach we have been using
NODEJS
• We’ve talked about this some in relation to the video we
watched a couple weeks ago.
• Our setup is WAY simpler, just those things you need
• NPM install
• Node [filename]
FIRST, GET THE PROJECT
• I’m going to ask you to fork my sample project this time
• You do this when you know you’ll be making changes that
don’t go back into the base project
• So fork https://github.com/derekja/simpleNode into your
github account
only one of you need do this per group, but it’s fine if more than one do
for now
I’d advise doing the same as for project 2 where one person forks and
gives commit permissions to the others
CLONE LOCALLY, MODIFY THE PROJECT
• Make sure you change it to use your database permissions and
your port number
• Then git add, commit, and push
LOG ONTO YOUR SERVER AND CLONE THE
PROJECT
• You can just do this from your home directory on this server,
no need to be in public_html anymore
• Can use the default name as we’ve been doing, but you can
also clone multiple forks and change the name of the directory
the go in. For instance:
• Git clone https://github.com/derekja/simpleNode.git
anotherSimpleNode
• This would clone into the “anotherSimpleNode” directory rather than
“simpleNode”
INSTALL THE DEPENDENCIES
• Because we are now using node, we have access to a wide array
of node extensions
• These all appear in the node_modules directory, but on your
newly cloned system that doesn’t exist yet so install it
• npm install
• (btw. There is a file in the project called .gitignore which lists
that files in the node_modules directory don’t get stored in
github. Why?)
TRY RUNNING IT
• Navigate into your directory on the server and type “node
express.js”
• The website will launch and will tell you what server port it is
using
• Make sure that this is your server port for your group! Edit it first, if not
• Now navigate to the site, for instance
• http://159.203.42.111:4001/ if you were running on port 4001
THE MORE COMPLEX EXAMPLES
• Stop the node.js server (cntrol-c) and then edit the other
examples to use your connection information and try firing
them up
• Only one server can run on each port at any time, so if multiple
people in your group are trying this make sure you coordinate!
• Try sql_ejs_example.js, although there are parts in there that
we haven’t talked about yet
REMEMBER SQLFIDDLE?
• http://sqlfiddle.com/#!9/1d643/23
• We’re going to use the same database structure but in our own
MySQL database now
DATABASE TO USE + MYSQL WORKBENCH
• Please don’t modify the testDB database, just leave it so
everyone’s samples can run
• You’ll want to create your own database for your project
• You’ll use MySQL Workbench for this
• Install that on your local machine from
https://dev.mysql.com/downloads/workbench/
CREATE A CONNECTION TO THE DATABASE
• This is on 206.12.96.242 (our cspubl server) and use the
default port of 3306
• In the email instructions I gave you a bit more complicated way
of connecting, but you can ignore that and just connect to the
port directly
• Use the username and password I sent each group in email!
1) Select a default
database (double click
on testDB)
2) Enter your query
statement
3) Press the lightning bolt
button
USE MYSQL WORKBENCH TO CREATE A NEW
DATABASE
• You’ll need to do this for your project group, but let’s just re-
create the employees database for now
• Open a new query window
• Create a new database (name it something unique, maybe use
your group name)
• drop database if exists group0DB;
• create database group0DB;
ADD A TABLE AND POPULATE IT
• Select the new database as the default
• DROP TABLE IF EXISTS employees;
• CREATE TABLE employees( id integer, name text,
• designation text, manager integer,
• hired_on date, salary integer,
• commission float, dept integer);
•
• INSERT INTO employees VALUES (1,'JOHNSON','ADMIN',6,'1990-12-17',18000,NULL,4);
• INSERT INTO employees VALUES (2,'HARDING','MANAGER',9,'1998-02-02',52000,300,3);
RUN A TEST QUERY
• Select * from employees
• (or whatever other modifiers you want to run on your query)
MODIFY YOUR PROJECT TO USE THE NEW
DATABASE
• Edit on your machine, git add, commit, push
• Git pull on the server
• Run it again “node sql_ejs_example.js”
EJS TEMPLATES
• Why can’t we just use client side javascript?
• Everything goes to the client, including your database server credentials
• There’s no access to filesystems, etc.
• So we need some server side code from node.js, how do we get
that to the client?
• Lots of ways – react, angular, etc.
• But a relatively simple way is EJS – Embedded JavaScript
• http://www.embeddedjs.com/getting_started.html
EJS TEMPLATE DEMO
A BIT MORE ON DATABASES
• I’ve only shown you the basic forEach loop over data from a
select statement. You can do much more than that and make
much more complex queries.
• Here is a good resource: https://www.sitepoint.com/using-
node-mysql-javascript-client/
• https://github.com/mysqljs/mysql
• http://www.w3resource.com/node.js/nodejs-mysql.php
EJS TEMPLATE DEMO WITH SQL
SCREEN
• Since the webserver only runs when you have a console open,
how do you get it to keep running?
• Best option for our use is a tool called screeen
• https://www.digitalocean.com/community/tutorials/how-to-
install-and-use-screen-on-an-ubuntu-cloud-server
• https://www.rackaid.com/blog/linux-screen-tutorial-and-
how-to/
LOCAL DEVELOPMENT ENVIRONMENT
• The main thing missing is just nodejs
• https://nodejs.org/en/
• You’ll want to make sure that it works from your git bash
window so that you can use node and git from the same
window. The workaround if you can’t figure that out is just to
use node and git from separate windows. Ask on slack if you
have problems.
MY DEVELOPMENT PROCESS
• Work locally in a visual studio code window
• Have one git bash window open that is just for running the
node server
• Have another git bash window open where I check in and do
anything else in the shell I need to do
• Go back and forth between editing and viewing in a browser
• Checkin and push to the server when things are working the
way I want them
• Or when I want to take a risky development path and want to make sure
I can get back
HOMEWORK 10
• Due by class time on March 22, can be done as a project group but submission must
name each person who contributed
• Take my simpleNode example and fork it
• Modify it to point to your own database and so that the database reflects your project
data structure (need not be final)
• Modify the sql_ejs_example.js to output from your database (make sure to use your own
port number as described in the email)
• Use a more complicated query to get a subset of the records (only pull from the database
for this exercise, there is no need to write back to the database right now.)
• Send me your github link and your website, along with the names of each person who
contributed

More Related Content

What's hot

Untangling - fall2017 - week 7
Untangling - fall2017 - week 7Untangling - fall2017 - week 7
Untangling - fall2017 - week 7
Derek Jacoby
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9
Derek Jacoby
 
Untangling - fall2017 - week 8
Untangling - fall2017 - week 8Untangling - fall2017 - week 8
Untangling - fall2017 - week 8
Derek Jacoby
 
Untangling fall2017 week1
Untangling fall2017 week1Untangling fall2017 week1
Untangling fall2017 week1
Derek Jacoby
 
Untangling - fall2017 - week 10
Untangling - fall2017 - week 10Untangling - fall2017 - week 10
Untangling - fall2017 - week 10
Derek Jacoby
 
Untangling11
Untangling11Untangling11
Untangling11
Derek Jacoby
 
Untangling6
Untangling6Untangling6
Untangling6
Derek Jacoby
 
Untangling the web9
Untangling the web9Untangling the web9
Untangling the web9
Derek Jacoby
 
Untangling the web - fall2017 - class 4
Untangling the web - fall2017 - class 4Untangling the web - fall2017 - class 4
Untangling the web - fall2017 - class 4
Derek Jacoby
 
Untangling the web10
Untangling the web10Untangling the web10
Untangling the web10
Derek Jacoby
 
Untangling spring week1
Untangling spring week1Untangling spring week1
Untangling spring week1
Derek Jacoby
 
Untangling - fall2017 - week6
Untangling - fall2017 - week6Untangling - fall2017 - week6
Untangling - fall2017 - week6
Derek Jacoby
 
Untangling4
Untangling4Untangling4
Untangling4
Derek Jacoby
 
Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?
Weng Wei
 
Untangling spring week2
Untangling spring week2Untangling spring week2
Untangling spring week2
Derek Jacoby
 
Copass + Ruby on Rails = <3 - From Simplicity to Complexity
Copass + Ruby on Rails = <3 - From Simplicity to ComplexityCopass + Ruby on Rails = <3 - From Simplicity to Complexity
Copass + Ruby on Rails = <3 - From Simplicity to Complexity
Augustin Riedinger
 
Untangling8
Untangling8Untangling8
Untangling8
Derek Jacoby
 
Cvcc performance tuning
Cvcc performance tuningCvcc performance tuning
Cvcc performance tuning
John McCaffrey
 
Don't make me wait! or Building High-Performance Web Applications
Don't make me wait! or Building High-Performance Web ApplicationsDon't make me wait! or Building High-Performance Web Applications
Don't make me wait! or Building High-Performance Web Applications
Stoyan Stefanov
 
Modern javascript
Modern javascriptModern javascript
Modern javascript
Kevin Ball
 

What's hot (20)

Untangling - fall2017 - week 7
Untangling - fall2017 - week 7Untangling - fall2017 - week 7
Untangling - fall2017 - week 7
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9
 
Untangling - fall2017 - week 8
Untangling - fall2017 - week 8Untangling - fall2017 - week 8
Untangling - fall2017 - week 8
 
Untangling fall2017 week1
Untangling fall2017 week1Untangling fall2017 week1
Untangling fall2017 week1
 
Untangling - fall2017 - week 10
Untangling - fall2017 - week 10Untangling - fall2017 - week 10
Untangling - fall2017 - week 10
 
Untangling11
Untangling11Untangling11
Untangling11
 
Untangling6
Untangling6Untangling6
Untangling6
 
Untangling the web9
Untangling the web9Untangling the web9
Untangling the web9
 
Untangling the web - fall2017 - class 4
Untangling the web - fall2017 - class 4Untangling the web - fall2017 - class 4
Untangling the web - fall2017 - class 4
 
Untangling the web10
Untangling the web10Untangling the web10
Untangling the web10
 
Untangling spring week1
Untangling spring week1Untangling spring week1
Untangling spring week1
 
Untangling - fall2017 - week6
Untangling - fall2017 - week6Untangling - fall2017 - week6
Untangling - fall2017 - week6
 
Untangling4
Untangling4Untangling4
Untangling4
 
Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?
 
Untangling spring week2
Untangling spring week2Untangling spring week2
Untangling spring week2
 
Copass + Ruby on Rails = <3 - From Simplicity to Complexity
Copass + Ruby on Rails = <3 - From Simplicity to ComplexityCopass + Ruby on Rails = <3 - From Simplicity to Complexity
Copass + Ruby on Rails = <3 - From Simplicity to Complexity
 
Untangling8
Untangling8Untangling8
Untangling8
 
Cvcc performance tuning
Cvcc performance tuningCvcc performance tuning
Cvcc performance tuning
 
Don't make me wait! or Building High-Performance Web Applications
Don't make me wait! or Building High-Performance Web ApplicationsDon't make me wait! or Building High-Performance Web Applications
Don't make me wait! or Building High-Performance Web Applications
 
Modern javascript
Modern javascriptModern javascript
Modern javascript
 

Viewers also liked

Untangling spring week3
Untangling spring week3Untangling spring week3
Untangling spring week3
Derek Jacoby
 
Untangling spring week6
Untangling spring week6Untangling spring week6
Untangling spring week6
Derek Jacoby
 
Untangling spring week7
Untangling spring week7Untangling spring week7
Untangling spring week7
Derek Jacoby
 
Untangling the web week 2 - SEO
Untangling the web week 2 - SEOUntangling the web week 2 - SEO
Untangling the web week 2 - SEO
Derek Jacoby
 
Untangling the web - week 3
Untangling the web - week 3Untangling the web - week 3
Untangling the web - week 3
Derek Jacoby
 
Tracxn Research - Mobile Advertising Landscape, February 2017
Tracxn Research - Mobile Advertising Landscape, February 2017Tracxn Research - Mobile Advertising Landscape, February 2017
Tracxn Research - Mobile Advertising Landscape, February 2017
Tracxn
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
ANOOP V S
 
2017 iosco research report on financial technologies (fintech)
2017 iosco research report on  financial technologies (fintech)2017 iosco research report on  financial technologies (fintech)
2017 iosco research report on financial technologies (fintech)
Ian Beckett
 
2015 Internet Trends Report
2015 Internet Trends Report2015 Internet Trends Report
2015 Internet Trends Report
IQbal KHan
 
Untangling the web week1
Untangling the web week1Untangling the web week1
Untangling the web week1
Derek Jacoby
 
Computershare (CPU) initiation report - well-priced quality franchise with fr...
Computershare (CPU) initiation report - well-priced quality franchise with fr...Computershare (CPU) initiation report - well-priced quality franchise with fr...
Computershare (CPU) initiation report - well-priced quality franchise with fr...
George Gabriel
 
What's New In Microsoft System Center 2016 & OMS
What's New In Microsoft System Center 2016 & OMSWhat's New In Microsoft System Center 2016 & OMS
What's New In Microsoft System Center 2016 & OMS
Asaf Nakash
 
Regulating corporate vc
Regulating corporate vcRegulating corporate vc
Regulating corporate vc
Ian Beckett
 
Best Practices for Reaching and Engaging Your Mobile Audience
Best Practices for Reaching and Engaging Your Mobile AudienceBest Practices for Reaching and Engaging Your Mobile Audience
Best Practices for Reaching and Engaging Your Mobile Audience
Origami Logic
 
Consolidate MySQL Shards Into Amazon Aurora Using AWS Database Migration Serv...
Consolidate MySQL Shards Into Amazon Aurora Using AWS Database Migration Serv...Consolidate MySQL Shards Into Amazon Aurora Using AWS Database Migration Serv...
Consolidate MySQL Shards Into Amazon Aurora Using AWS Database Migration Serv...
Amazon Web Services
 
Tracxn Research - Chatbots Landscape, February 2017
Tracxn Research - Chatbots Landscape, February 2017Tracxn Research - Chatbots Landscape, February 2017
Tracxn Research - Chatbots Landscape, February 2017
Tracxn
 
Comparing 30 MongoDB operations with Oracle SQL statements
Comparing 30 MongoDB operations with Oracle SQL statementsComparing 30 MongoDB operations with Oracle SQL statements
Comparing 30 MongoDB operations with Oracle SQL statements
Lucas Jellema
 
Tracxn Research - Healthcare Analytics Landscape, February 2017
Tracxn Research - Healthcare Analytics Landscape, February 2017Tracxn Research - Healthcare Analytics Landscape, February 2017
Tracxn Research - Healthcare Analytics Landscape, February 2017
Tracxn
 

Viewers also liked (18)

Untangling spring week3
Untangling spring week3Untangling spring week3
Untangling spring week3
 
Untangling spring week6
Untangling spring week6Untangling spring week6
Untangling spring week6
 
Untangling spring week7
Untangling spring week7Untangling spring week7
Untangling spring week7
 
Untangling the web week 2 - SEO
Untangling the web week 2 - SEOUntangling the web week 2 - SEO
Untangling the web week 2 - SEO
 
Untangling the web - week 3
Untangling the web - week 3Untangling the web - week 3
Untangling the web - week 3
 
Tracxn Research - Mobile Advertising Landscape, February 2017
Tracxn Research - Mobile Advertising Landscape, February 2017Tracxn Research - Mobile Advertising Landscape, February 2017
Tracxn Research - Mobile Advertising Landscape, February 2017
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
2017 iosco research report on financial technologies (fintech)
2017 iosco research report on  financial technologies (fintech)2017 iosco research report on  financial technologies (fintech)
2017 iosco research report on financial technologies (fintech)
 
2015 Internet Trends Report
2015 Internet Trends Report2015 Internet Trends Report
2015 Internet Trends Report
 
Untangling the web week1
Untangling the web week1Untangling the web week1
Untangling the web week1
 
Computershare (CPU) initiation report - well-priced quality franchise with fr...
Computershare (CPU) initiation report - well-priced quality franchise with fr...Computershare (CPU) initiation report - well-priced quality franchise with fr...
Computershare (CPU) initiation report - well-priced quality franchise with fr...
 
What's New In Microsoft System Center 2016 & OMS
What's New In Microsoft System Center 2016 & OMSWhat's New In Microsoft System Center 2016 & OMS
What's New In Microsoft System Center 2016 & OMS
 
Regulating corporate vc
Regulating corporate vcRegulating corporate vc
Regulating corporate vc
 
Best Practices for Reaching and Engaging Your Mobile Audience
Best Practices for Reaching and Engaging Your Mobile AudienceBest Practices for Reaching and Engaging Your Mobile Audience
Best Practices for Reaching and Engaging Your Mobile Audience
 
Consolidate MySQL Shards Into Amazon Aurora Using AWS Database Migration Serv...
Consolidate MySQL Shards Into Amazon Aurora Using AWS Database Migration Serv...Consolidate MySQL Shards Into Amazon Aurora Using AWS Database Migration Serv...
Consolidate MySQL Shards Into Amazon Aurora Using AWS Database Migration Serv...
 
Tracxn Research - Chatbots Landscape, February 2017
Tracxn Research - Chatbots Landscape, February 2017Tracxn Research - Chatbots Landscape, February 2017
Tracxn Research - Chatbots Landscape, February 2017
 
Comparing 30 MongoDB operations with Oracle SQL statements
Comparing 30 MongoDB operations with Oracle SQL statementsComparing 30 MongoDB operations with Oracle SQL statements
Comparing 30 MongoDB operations with Oracle SQL statements
 
Tracxn Research - Healthcare Analytics Landscape, February 2017
Tracxn Research - Healthcare Analytics Landscape, February 2017Tracxn Research - Healthcare Analytics Landscape, February 2017
Tracxn Research - Healthcare Analytics Landscape, February 2017
 

Similar to Untangling spring week10

My first powershell script
My first powershell scriptMy first powershell script
My first powershell script
David Cobb
 
Database continuous integration, unit test and functional test
Database continuous integration, unit test and functional testDatabase continuous integration, unit test and functional test
Database continuous integration, unit test and functional test
Harry Zheng
 
SharePoint Framework 101 (SPFx)
SharePoint Framework 101 (SPFx)SharePoint Framework 101 (SPFx)
SharePoint Framework 101 (SPFx)
Matthew J. Bailey , MCT
 
Test like a_boss
Test like a_bossTest like a_boss
Test like a_boss
Giuseppe Maxia
 
Intro to SpringBatch NoSQL 2021
Intro to SpringBatch NoSQL 2021Intro to SpringBatch NoSQL 2021
Intro to SpringBatch NoSQL 2021
Slobodan Lohja
 
Drupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDrupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 version
David Lanier
 
Hosting Ruby Web Apps
Hosting Ruby Web AppsHosting Ruby Web Apps
Hosting Ruby Web Apps
Michael Reinsch
 
5 Common Mistakes You are Making on your Website
 5 Common Mistakes You are Making on your Website 5 Common Mistakes You are Making on your Website
5 Common Mistakes You are Making on your WebsiteAcquia
 
Performant Django - Ara Anjargolian
Performant Django - Ara AnjargolianPerformant Django - Ara Anjargolian
Performant Django - Ara Anjargolian
Hakka Labs
 
Automating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server apiAutomating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server api
Yonni Mendes
 
Dapper: the microORM that will change your life
Dapper: the microORM that will change your lifeDapper: the microORM that will change your life
Dapper: the microORM that will change your life
Davide Mauri
 
rsyslog meets docker
rsyslog meets dockerrsyslog meets docker
rsyslog meets docker
Rainer Gerhards
 
What is Node.js? (ICON UK)
What is Node.js? (ICON UK)What is Node.js? (ICON UK)
What is Node.js? (ICON UK)
Tim Davis
 
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
August Webinar - Water Cooler Talks: A Look into a Developer's WorkbenchAugust Webinar - Water Cooler Talks: A Look into a Developer's Workbench
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
Howard Greenberg
 
Performance Tuning in the Trenches
Performance Tuning in the TrenchesPerformance Tuning in the Trenches
Performance Tuning in the Trenches
Donald Belcham
 
SOUG_Deployment__Automation_DB
SOUG_Deployment__Automation_DBSOUG_Deployment__Automation_DB
SOUG_Deployment__Automation_DBUniFabric
 
SynapseIndia drupal presentation on drupal info
SynapseIndia drupal  presentation on drupal infoSynapseIndia drupal  presentation on drupal info
SynapseIndia drupal presentation on drupal info
Synapseindiappsdevelopment
 
IBM Connections – Managing Growth and Expansion
IBM Connections – Managing Growth and ExpansionIBM Connections – Managing Growth and Expansion
IBM Connections – Managing Growth and Expansion
LetsConnect
 
The Future of Database Development
The Future of Database DevelopmentThe Future of Database Development
The Future of Database Development
Steve Jones
 
Hadoop Demystified + Automation Smackdown! Austin JUG June 24 2014
Hadoop Demystified + Automation Smackdown!  Austin JUG June 24 2014Hadoop Demystified + Automation Smackdown!  Austin JUG June 24 2014
Hadoop Demystified + Automation Smackdown! Austin JUG June 24 2014
datafundamentals
 

Similar to Untangling spring week10 (20)

My first powershell script
My first powershell scriptMy first powershell script
My first powershell script
 
Database continuous integration, unit test and functional test
Database continuous integration, unit test and functional testDatabase continuous integration, unit test and functional test
Database continuous integration, unit test and functional test
 
SharePoint Framework 101 (SPFx)
SharePoint Framework 101 (SPFx)SharePoint Framework 101 (SPFx)
SharePoint Framework 101 (SPFx)
 
Test like a_boss
Test like a_bossTest like a_boss
Test like a_boss
 
Intro to SpringBatch NoSQL 2021
Intro to SpringBatch NoSQL 2021Intro to SpringBatch NoSQL 2021
Intro to SpringBatch NoSQL 2021
 
Drupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDrupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 version
 
Hosting Ruby Web Apps
Hosting Ruby Web AppsHosting Ruby Web Apps
Hosting Ruby Web Apps
 
5 Common Mistakes You are Making on your Website
 5 Common Mistakes You are Making on your Website 5 Common Mistakes You are Making on your Website
5 Common Mistakes You are Making on your Website
 
Performant Django - Ara Anjargolian
Performant Django - Ara AnjargolianPerformant Django - Ara Anjargolian
Performant Django - Ara Anjargolian
 
Automating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server apiAutomating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server api
 
Dapper: the microORM that will change your life
Dapper: the microORM that will change your lifeDapper: the microORM that will change your life
Dapper: the microORM that will change your life
 
rsyslog meets docker
rsyslog meets dockerrsyslog meets docker
rsyslog meets docker
 
What is Node.js? (ICON UK)
What is Node.js? (ICON UK)What is Node.js? (ICON UK)
What is Node.js? (ICON UK)
 
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
August Webinar - Water Cooler Talks: A Look into a Developer's WorkbenchAugust Webinar - Water Cooler Talks: A Look into a Developer's Workbench
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
 
Performance Tuning in the Trenches
Performance Tuning in the TrenchesPerformance Tuning in the Trenches
Performance Tuning in the Trenches
 
SOUG_Deployment__Automation_DB
SOUG_Deployment__Automation_DBSOUG_Deployment__Automation_DB
SOUG_Deployment__Automation_DB
 
SynapseIndia drupal presentation on drupal info
SynapseIndia drupal  presentation on drupal infoSynapseIndia drupal  presentation on drupal info
SynapseIndia drupal presentation on drupal info
 
IBM Connections – Managing Growth and Expansion
IBM Connections – Managing Growth and ExpansionIBM Connections – Managing Growth and Expansion
IBM Connections – Managing Growth and Expansion
 
The Future of Database Development
The Future of Database DevelopmentThe Future of Database Development
The Future of Database Development
 
Hadoop Demystified + Automation Smackdown! Austin JUG June 24 2014
Hadoop Demystified + Automation Smackdown!  Austin JUG June 24 2014Hadoop Demystified + Automation Smackdown!  Austin JUG June 24 2014
Hadoop Demystified + Automation Smackdown! Austin JUG June 24 2014
 

Recently uploaded

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
JEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questionsJEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questions
ShivajiThube2
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 

Recently uploaded (20)

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
JEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questionsJEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questions
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 

Untangling spring week10

  • 1. UNTANGLING THE WEB WEEK 10 – SERVERS AND DATABASES, OH MY
  • 2. AGENDA • Server setup – a runthrough of the whole process • Databases • EJS and html templates • Local build environments • Homework
  • 3. HOMEWORK 8 REVIEW • Some folks are having a hard time with this one • I am not looking for the database to populate the map markers, but only the UI to do so • Ignore the problem of when you refresh the page the database markers do not appear • I suggest working on everything but the map first
  • 4. NEW SERVER FOR THE THIRD PROJECT • The cspubl server you have been using has been great. The webserver serves your page and you don’t need to sorry about it. • Now we want a server, though, so I’ve stood up a new machine. This is on Digital Ocean (if we have time we’ll talk about that process) • You’ll need to log onto that machine using the same type of SSH approach we have been using
  • 5. NODEJS • We’ve talked about this some in relation to the video we watched a couple weeks ago. • Our setup is WAY simpler, just those things you need • NPM install • Node [filename]
  • 6. FIRST, GET THE PROJECT • I’m going to ask you to fork my sample project this time • You do this when you know you’ll be making changes that don’t go back into the base project • So fork https://github.com/derekja/simpleNode into your github account only one of you need do this per group, but it’s fine if more than one do for now I’d advise doing the same as for project 2 where one person forks and gives commit permissions to the others
  • 7. CLONE LOCALLY, MODIFY THE PROJECT • Make sure you change it to use your database permissions and your port number • Then git add, commit, and push
  • 8. LOG ONTO YOUR SERVER AND CLONE THE PROJECT • You can just do this from your home directory on this server, no need to be in public_html anymore • Can use the default name as we’ve been doing, but you can also clone multiple forks and change the name of the directory the go in. For instance: • Git clone https://github.com/derekja/simpleNode.git anotherSimpleNode • This would clone into the “anotherSimpleNode” directory rather than “simpleNode”
  • 9. INSTALL THE DEPENDENCIES • Because we are now using node, we have access to a wide array of node extensions • These all appear in the node_modules directory, but on your newly cloned system that doesn’t exist yet so install it • npm install • (btw. There is a file in the project called .gitignore which lists that files in the node_modules directory don’t get stored in github. Why?)
  • 10. TRY RUNNING IT • Navigate into your directory on the server and type “node express.js” • The website will launch and will tell you what server port it is using • Make sure that this is your server port for your group! Edit it first, if not • Now navigate to the site, for instance • http://159.203.42.111:4001/ if you were running on port 4001
  • 11. THE MORE COMPLEX EXAMPLES • Stop the node.js server (cntrol-c) and then edit the other examples to use your connection information and try firing them up • Only one server can run on each port at any time, so if multiple people in your group are trying this make sure you coordinate! • Try sql_ejs_example.js, although there are parts in there that we haven’t talked about yet
  • 12. REMEMBER SQLFIDDLE? • http://sqlfiddle.com/#!9/1d643/23 • We’re going to use the same database structure but in our own MySQL database now
  • 13. DATABASE TO USE + MYSQL WORKBENCH • Please don’t modify the testDB database, just leave it so everyone’s samples can run • You’ll want to create your own database for your project • You’ll use MySQL Workbench for this • Install that on your local machine from https://dev.mysql.com/downloads/workbench/
  • 14. CREATE A CONNECTION TO THE DATABASE • This is on 206.12.96.242 (our cspubl server) and use the default port of 3306 • In the email instructions I gave you a bit more complicated way of connecting, but you can ignore that and just connect to the port directly • Use the username and password I sent each group in email!
  • 15.
  • 16.
  • 17. 1) Select a default database (double click on testDB) 2) Enter your query statement 3) Press the lightning bolt button
  • 18. USE MYSQL WORKBENCH TO CREATE A NEW DATABASE • You’ll need to do this for your project group, but let’s just re- create the employees database for now • Open a new query window • Create a new database (name it something unique, maybe use your group name) • drop database if exists group0DB; • create database group0DB;
  • 19. ADD A TABLE AND POPULATE IT • Select the new database as the default • DROP TABLE IF EXISTS employees; • CREATE TABLE employees( id integer, name text, • designation text, manager integer, • hired_on date, salary integer, • commission float, dept integer); • • INSERT INTO employees VALUES (1,'JOHNSON','ADMIN',6,'1990-12-17',18000,NULL,4); • INSERT INTO employees VALUES (2,'HARDING','MANAGER',9,'1998-02-02',52000,300,3);
  • 20. RUN A TEST QUERY • Select * from employees • (or whatever other modifiers you want to run on your query)
  • 21. MODIFY YOUR PROJECT TO USE THE NEW DATABASE • Edit on your machine, git add, commit, push • Git pull on the server • Run it again “node sql_ejs_example.js”
  • 22. EJS TEMPLATES • Why can’t we just use client side javascript? • Everything goes to the client, including your database server credentials • There’s no access to filesystems, etc. • So we need some server side code from node.js, how do we get that to the client? • Lots of ways – react, angular, etc. • But a relatively simple way is EJS – Embedded JavaScript • http://www.embeddedjs.com/getting_started.html
  • 24. A BIT MORE ON DATABASES • I’ve only shown you the basic forEach loop over data from a select statement. You can do much more than that and make much more complex queries. • Here is a good resource: https://www.sitepoint.com/using- node-mysql-javascript-client/ • https://github.com/mysqljs/mysql • http://www.w3resource.com/node.js/nodejs-mysql.php
  • 25. EJS TEMPLATE DEMO WITH SQL
  • 26. SCREEN • Since the webserver only runs when you have a console open, how do you get it to keep running? • Best option for our use is a tool called screeen • https://www.digitalocean.com/community/tutorials/how-to- install-and-use-screen-on-an-ubuntu-cloud-server • https://www.rackaid.com/blog/linux-screen-tutorial-and- how-to/
  • 27. LOCAL DEVELOPMENT ENVIRONMENT • The main thing missing is just nodejs • https://nodejs.org/en/ • You’ll want to make sure that it works from your git bash window so that you can use node and git from the same window. The workaround if you can’t figure that out is just to use node and git from separate windows. Ask on slack if you have problems.
  • 28. MY DEVELOPMENT PROCESS • Work locally in a visual studio code window • Have one git bash window open that is just for running the node server • Have another git bash window open where I check in and do anything else in the shell I need to do • Go back and forth between editing and viewing in a browser • Checkin and push to the server when things are working the way I want them • Or when I want to take a risky development path and want to make sure I can get back
  • 29. HOMEWORK 10 • Due by class time on March 22, can be done as a project group but submission must name each person who contributed • Take my simpleNode example and fork it • Modify it to point to your own database and so that the database reflects your project data structure (need not be final) • Modify the sql_ejs_example.js to output from your database (make sure to use your own port number as described in the email) • Use a more complicated query to get a subset of the records (only pull from the database for this exercise, there is no need to write back to the database right now.) • Send me your github link and your website, along with the names of each person who contributed