From 5e6a6f03ba470164bab2e6c59bc61c67dc0af9e3 Mon Sep 17 00:00:00 2001 From: dalmianihar Date: Sat, 17 Sep 2016 04:08:31 -0700 Subject: [PATCH 1/4] pushing master --- Labs/Lab_5-Javascript_Basics/js-basics.js | 33 ++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Labs/Lab_5-Javascript_Basics/js-basics.js b/Labs/Lab_5-Javascript_Basics/js-basics.js index 1c6ae71..7863086 100644 --- a/Labs/Lab_5-Javascript_Basics/js-basics.js +++ b/Labs/Lab_5-Javascript_Basics/js-basics.js @@ -6,6 +6,21 @@ // 1. Include 'alt' and 'src' as keys within each of the 3 objects - values should correspond to the cat's name and img source (you can re-use name and URLs from the existing cat elements in the HTML) // 2. Put these 3 objects into an array - you can do this programmatically or hard-coded // 3. We created the handler for the 'Cats from Obj' button in the HTML. Use the function below to trigger. +var cat1 = { + src: "https://pbs.twimg.com/profile_images/424484505915621376/EOwsjaMZ_400x400.png", + alt: "meow1" +} + + +var cat2 = { + src: "https://pbs.twimg.com/profile_images/447460759329460224/mt2UmwGG_400x400.jpeg", + alt: "meow2" +} + +cat_array = [cat1,cat2] + +console.log(cat_array) + function populateFromObj() { // 1. Iterate through each 'cat' object in the list you created above @@ -17,7 +32,23 @@ function populateFromObj() { // e) set the p element's innerHTML to the 'alt' value of the object // f) append the img and p elements to the div from step a // g) append the div element to the parent container - + for (var i = 0; i < cat_array.length; i++){ + var newDiv = document.createElement("div"); + newDiv.className += "id-grid_item" + //console.log(newDiv) + var newImg = document.createElement("img"); + var imgSrc = cat_array[i].src; + var imgAlt = cat_array[i].alt; + + newImg.setAttribute("src", imgSrc); + newImg.setAttribute("alt", imgAlt); + + newDiv.appendChild(newImg); + + var mainContainer = document.getElementsByClassName("main-container")[0]; + console.log(mainContainer) + mainContainer.appendChild(newDiv); + } // *** Hints: // .createElement() // .setAttribute() From da6c7dcf8f0dd48cf60de770f036ab29d8c12f05 Mon Sep 17 00:00:00 2001 From: dalmianihar Date: Sat, 17 Sep 2016 04:08:31 -0700 Subject: [PATCH 2/4] pushing master --- Labs/Lab_5-Javascript_Basics/js-basics.js | 33 ++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Labs/Lab_5-Javascript_Basics/js-basics.js b/Labs/Lab_5-Javascript_Basics/js-basics.js index 1c6ae71..7863086 100644 --- a/Labs/Lab_5-Javascript_Basics/js-basics.js +++ b/Labs/Lab_5-Javascript_Basics/js-basics.js @@ -6,6 +6,21 @@ // 1. Include 'alt' and 'src' as keys within each of the 3 objects - values should correspond to the cat's name and img source (you can re-use name and URLs from the existing cat elements in the HTML) // 2. Put these 3 objects into an array - you can do this programmatically or hard-coded // 3. We created the handler for the 'Cats from Obj' button in the HTML. Use the function below to trigger. +var cat1 = { + src: "https://pbs.twimg.com/profile_images/424484505915621376/EOwsjaMZ_400x400.png", + alt: "meow1" +} + + +var cat2 = { + src: "https://pbs.twimg.com/profile_images/447460759329460224/mt2UmwGG_400x400.jpeg", + alt: "meow2" +} + +cat_array = [cat1,cat2] + +console.log(cat_array) + function populateFromObj() { // 1. Iterate through each 'cat' object in the list you created above @@ -17,7 +32,23 @@ function populateFromObj() { // e) set the p element's innerHTML to the 'alt' value of the object // f) append the img and p elements to the div from step a // g) append the div element to the parent container - + for (var i = 0; i < cat_array.length; i++){ + var newDiv = document.createElement("div"); + newDiv.className += "id-grid_item" + //console.log(newDiv) + var newImg = document.createElement("img"); + var imgSrc = cat_array[i].src; + var imgAlt = cat_array[i].alt; + + newImg.setAttribute("src", imgSrc); + newImg.setAttribute("alt", imgAlt); + + newDiv.appendChild(newImg); + + var mainContainer = document.getElementsByClassName("main-container")[0]; + console.log(mainContainer) + mainContainer.appendChild(newDiv); + } // *** Hints: // .createElement() // .setAttribute() From fe8434b921fbba11c2c1655b3e06a7e99d4e7c05 Mon Sep 17 00:00:00 2001 From: dalmianihar Date: Tue, 27 Sep 2016 15:45:30 -0700 Subject: [PATCH 3/4] ABc --- .../~$structions HW2 Responsive_Design.docx | Bin 162 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Assignment/Homework_2 - CSS_ResponsiveDesign/~$structions HW2 Responsive_Design.docx diff --git a/Assignment/Homework_2 - CSS_ResponsiveDesign/~$structions HW2 Responsive_Design.docx b/Assignment/Homework_2 - CSS_ResponsiveDesign/~$structions HW2 Responsive_Design.docx deleted file mode 100644 index 37240c44e0d81bf1d9b2bc8fa4d7f56be2581eba..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 162 zcmd;ePAtmFSMbR!EX_>GXCM;rGB`6NG88f7Fyu2RF!(TJG88hD0?8C09|RmeUT6Vf zkNCg)4c1Jb#-bCs7=$%|a#!B!Fg=L)yT3RyJx|{=uehYBG`S=*Kd)HT$bb=@#Cno>^ From f447d7c3ca8813086748dbb161cda52cb53759d8 Mon Sep 17 00:00:00 2001 From: dalmianihar Date: Thu, 6 Oct 2016 11:44:08 -0700 Subject: [PATCH 4/4] submitting Lab 9 --- Labs/Lab 9 - Flask/.spyderworkspace | Bin 0 -> 50 bytes Labs/Lab 9 - Flask/app/__init__.py | 4 + Labs/Lab 9 - Flask/app/__init__.pyc | Bin 0 -> 278 bytes .../app/__pycache__/__init__.cpython-35.pyc | Bin 0 -> 269 bytes .../app/__pycache__/views.cpython-35.pyc | Bin 0 -> 1988 bytes Labs/Lab 9 - Flask/app/static/interactions.js | 43 ++++ Labs/Lab 9 - Flask/app/static/main.css | 225 ++++++++++++++++++ Labs/Lab 9 - Flask/app/templates/base.html | 33 +++ Labs/Lab 9 - Flask/app/templates/login.html | 18 ++ .../app/templates/not_authorized.html | 13 + .../app/templates/page_not_found.html | 12 + Labs/Lab 9 - Flask/app/templates/results.html | 34 +++ Labs/Lab 9 - Flask/app/templates/survey.html | 40 ++++ Labs/Lab 9 - Flask/app/views.py | 51 ++++ Labs/Lab 9 - Flask/app/views.pyc | Bin 0 -> 2299 bytes Labs/Lab 9 - Flask/run.py | 3 + 16 files changed, 476 insertions(+) create mode 100644 Labs/Lab 9 - Flask/.spyderworkspace create mode 100644 Labs/Lab 9 - Flask/app/__init__.py create mode 100644 Labs/Lab 9 - Flask/app/__init__.pyc create mode 100644 Labs/Lab 9 - Flask/app/__pycache__/__init__.cpython-35.pyc create mode 100644 Labs/Lab 9 - Flask/app/__pycache__/views.cpython-35.pyc create mode 100644 Labs/Lab 9 - Flask/app/static/interactions.js create mode 100644 Labs/Lab 9 - Flask/app/static/main.css create mode 100644 Labs/Lab 9 - Flask/app/templates/base.html create mode 100644 Labs/Lab 9 - Flask/app/templates/login.html create mode 100644 Labs/Lab 9 - Flask/app/templates/not_authorized.html create mode 100644 Labs/Lab 9 - Flask/app/templates/page_not_found.html create mode 100644 Labs/Lab 9 - Flask/app/templates/results.html create mode 100644 Labs/Lab 9 - Flask/app/templates/survey.html create mode 100644 Labs/Lab 9 - Flask/app/views.py create mode 100644 Labs/Lab 9 - Flask/app/views.pyc create mode 100644 Labs/Lab 9 - Flask/run.py diff --git a/Labs/Lab 9 - Flask/.spyderworkspace b/Labs/Lab 9 - Flask/.spyderworkspace new file mode 100644 index 0000000000000000000000000000000000000000..be24de3f58bb019a1446608c26e01e2dc4121a3e GIT binary patch literal 50 zcmZo*sx4&H2<0s(%FjwoE{QKlEXgP?WQq-C$xF;lEo6@1WME+MNla2m%SkNGE@Uay F0|1r^4`~1Z literal 0 HcmV?d00001 diff --git a/Labs/Lab 9 - Flask/app/__init__.py b/Labs/Lab 9 - Flask/app/__init__.py new file mode 100644 index 0000000..9a4e940 --- /dev/null +++ b/Labs/Lab 9 - Flask/app/__init__.py @@ -0,0 +1,4 @@ +from flask import Flask + +myapp = Flask(__name__) +from app import views diff --git a/Labs/Lab 9 - Flask/app/__init__.pyc b/Labs/Lab 9 - Flask/app/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4d4e5adeb859807192e959f25c2546b087e0a2ed GIT binary patch literal 278 zcmYjLOA5j;5S_GEL=-%N%dR9_Kd7L%5*LatBrv2lLNTeOiNCe?^D-Vlr$x~r^JZQi z^Je^Kvp(uSHaqx)M|DhTIYCU1fd()PwhWkJpggz}@k`AET>%roHUJj;unH?Ql)NZH zMx6@?W?I_AkDe2Cv5TlUe3``lh-p97D=Kuw9~)o>*Iz zTM^}H&XIF2rpg}NF%wd&tC-8EU2YNNA`p`_afqGlRxTWvV|>zTSh(Bb{Fc{XZ~f0Y AU;qFB literal 0 HcmV?d00001 diff --git a/Labs/Lab 9 - Flask/app/__pycache__/__init__.cpython-35.pyc b/Labs/Lab 9 - Flask/app/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0da93b9222e0b4673b5ce64177a4ce14469a61ff GIT binary patch literal 269 zcmX|4O-sW-5S>Y~wv-k;dCoP5mg22NM6f8Lw1-j(VPT2Q2*KSn>^7C0{Wbojz4qk6 zKj5j8AP)21d^~2})o3($u79?V0B~abN5I`3!%dlTP6Q2L5K;sr1Pb7jhp^KE&=D8` zsQ}DFSSQgpUqOOiJm}25x6QGj54TJ%Qt{TVY-`~AN|l)*rMxgrR#iS^vLQ=fV0&CT z`d!`6<;Ib9azR?l#eP>CDi2ORtzNQM`G;9Njyt<}UE3oyvNK}wTJl$^R8bZOr6yJ5 T`!{Bv*P3pTJzT_e84U3Z=o3Rg literal 0 HcmV?d00001 diff --git a/Labs/Lab 9 - Flask/app/__pycache__/views.cpython-35.pyc b/Labs/Lab 9 - Flask/app/__pycache__/views.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..77a3dfade86438a06a3a1df8a47b9f4c8eeb6356 GIT binary patch literal 1988 zcmaJ>UvC>l5TCvOb}qJ)l(ax8d8_=81o{T5P$30WQMm{gRXSNj7vDN@a_2L<=RmCV zDSQL^CHPAF%2VGF4}Ib{dv;=4#MwJHJ3Bi!e||ID>+8)|zyJN>r-0~BT6ui%kFa!0 z5M}ra%83d=i6FsyhjNDsmlBr>j}ngxpAw&nfRccUkdly!h?1z*b}4UA(jeKO(Ww)0{xad;9d*?MLsw<3NT%^-!H!z`+KhLDD zOk2rGCe>jji)o%#(u7)SJuW9EQZgGWIjl@LQ~BYjR3?ymm`-Ky^&OadBlhRP{usA^ z9kO|Tkb3g44zTni5LDr%&3#357La;Cl_2n_#`{PT&MJp}%sjf}%!xklZEpK0TE83g z44G)ArJAILoUiGbI+quFCsmOf&x)FPc|4w2N!L{j0~Il0Ke|H2c>O`Dh1Z*>2cHjq zgeg6EEc1NuxE#(3IjQvE$+M^F(O|JY+u7auCQtR*PTziPFyajk9}JMZ!TDJJqW7j3 z#<#JDFsz#(N9Qgc8!8ua z6V%Qb59KY4dn~IugXk_&9GXqs3Tg8#-$u3pR&%P!X^Ue^#Y4F`6Br5&CpHH<+~9C%lQ`LB1uT!Y)K!7XS^^b+c}Sf?nS9V3?r z)I+_lr55fi^;e~KsIW9xm4;k#mWHd+Xeo_WrH!Suxhh>-N@GZUs)rGp5Ba`CbZxeN zCEPxrby&AX(ne3MAssh`NP=TKI*dOo^HL>%P?;ssc{)rh%#S2~(jT6bWqyF}(MdFt zUrB&W&Ko1Sdt})p9LX<7l~i+_?xvQDmDIDm(zc(~I=*OHb#;D_dRk7joUb-~u+s2c zHMPy;HWSz;O2iA;1ih2egbFK-lfgx2EZ_Je-sjX6bB_*$Ax}OsRTUp+l7_)!RdMC@!jvAEZ`AAT6z-}(nN CzKfIq literal 0 HcmV?d00001 diff --git a/Labs/Lab 9 - Flask/app/static/interactions.js b/Labs/Lab 9 - Flask/app/static/interactions.js new file mode 100644 index 0000000..04c7724 --- /dev/null +++ b/Labs/Lab 9 - Flask/app/static/interactions.js @@ -0,0 +1,43 @@ +$('#submit-survey').on('click', function submitSurvey() { + var gender = $("input[name=gender]").val(); + var color = $("input[name=color]").val(); + var food = $("input[name=food]").val(); + var vacation = $("input[name=vacation]").val(); + var ISchoolClass = $("input[name=ISchoolClass]").val(); + var feBefore = $("input[name=front-end-before]").val(); + var feAfter = $("input[name=front-end-after]").val(); + $.post("submit-survey", + { + gender: gender, + color: color, + food: food, + vacation: vacation, + ISchoolClass: ISchoolClass, + feBefore: feBefore, + feAfter: feAfter}, + function(data) { + $("html").html(data); + }) +}); + +$("#results-email-container").on('click', '#email-results-button', function emailResults() { + console.log($(this)); +}); + +$("#site-title-wrapper").on('click', function goHome() { + window.location.href = '/'; +}); + +$(document).ready(function applySliderLabels() { + var currentValue = $("#fe-before").val(); + $("#fe-before").next().html(currentValue); + + currentValue = $("#fe-after").val(); + $("#fe-after").next().html(currentValue); +}); + + +$("input[type='range']").on('change', function updateLabel() { + var currentValue = $(this).val(); + $(this).next().html(currentValue); +}); \ No newline at end of file diff --git a/Labs/Lab 9 - Flask/app/static/main.css b/Labs/Lab 9 - Flask/app/static/main.css new file mode 100644 index 0000000..ccd8971 --- /dev/null +++ b/Labs/Lab 9 - Flask/app/static/main.css @@ -0,0 +1,225 @@ +/*----------------- CSS RESET ------------------*/ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} + +/*----------------- CSS RESET ------------------*/ + +html, body { + background-color: #f9f9f9; + font-family: 'Open Sans', sans-serif; + font-size: 16px; +} + +header { + background-color: #1abc9c; + box-shadow: 0 2px 6px 1px #a7a7a7; + color: #ecf0f1; + height: 5rem; +} + +footer { + background-color: #16a085; + bottom: 0; + color: #ecf0f1; + height: 7rem; + margin-top: 2em; + text-align: center; + width: 100%; +} + +footer p { + height: 7rem; + line-height: 7rem; +} + +h1, h3 { + padding: 4px; +} + +h1 { + font-size: 2rem; + font-weight: bold; +} + +h3 { + font-size: 1.4rem; +} + +a { + text-decoration: none; +} + +input[type="text"], input[type="range"] { + border: 1px solid #bdc3c7; + border-radius: 2px; + margin-left: 1rem; + vertical-align: middle; +} + +input[type=range]{ + -webkit-appearance: none; +} + +input[type=range]::-webkit-slider-thumb { + -webkit-appearance: none; + border: none; + height: 1.2rem; + width: 1.2rem; + border-radius: 50%; + background: #1abc9c; + margin-top: -.5rem; +} + +input[type=range]::-webkit-slider-runnable-track { + background: #ccc; + height: .2rem; +} + +.action-button { + background-color: #1abc9c; + border: none; + border-bottom: 3px solid #16a085; + border-radius: 2px; + color: #ecf0f1; + display: inline-block; + font-size: 1rem; + font-weight: bold; + height: 3rem; + padding: 4px; + width: 6rem; +} + +.action-button:hover { + background-color: #16a085; +} + +#site-title-wrapper { + display: inline-block; + height: 5rem; + width: 15%; +} + +#site-icon-wrapper { + display: inline-block; + margin-left: 1rem; + margin-top: -.5rem; + vertical-align: middle; + width: 2.5rem; +} + +#site-icon-wrapper img { + display: inline-block; + max-height: 100%; + max-width: 100% +} + +#site-title { + display: inline-block; + font-weight: bold; + height: 5rem; + line-height: 5rem; + margin-left: .1rem; +} + +#username { + margin-right: .7rem; +} + +#logout { + float: right; + height: inherit; + line-height: 5rem; + margin-right: 1rem; +} + +#logout-button { + background-color: #ecf0f1; + border-bottom-color: #bdc3c7; + color: #222222; + height: 2.5rem; + width: 5rem; +} + +#logout-button:hover { + background-color: #bdc3c7; +} + +#content { + margin-top: 2rem; + text-align: center; + width: 100%; +} + +.main-container { + background: #ecf0f1; + border-radius: 4px; + box-shadow: 0px 2px 10px 2px #95a5a6; + display: block; + min-height: 50vh; + margin: 2rem 0 0 25%; + padding: 1rem; + text-align: left; + width: 50%; +} + +.survey-item, .result-item, #results-email-container { + box-sizing: border-box; + display: block; + margin: 1.5rem 0; + padding: 4px; +} + +.survey-item span { + font-size: 1rem; + margin-left: 1rem; +} + +#email-results-button, #goHome { + height: 2rem; + line-height: 2rem; + margin-left: 1rem; + text-align: center; +} + diff --git a/Labs/Lab 9 - Flask/app/templates/base.html b/Labs/Lab 9 - Flask/app/templates/base.html new file mode 100644 index 0000000..ffba46d --- /dev/null +++ b/Labs/Lab 9 - Flask/app/templates/base.html @@ -0,0 +1,33 @@ + + + + + + {% block title %}{% endblock %} - Ape Ask + + + + {% block styles %}{% endblock %} + + + + +
+ {% block header %} +
+
+ +
+

Ape Ask

+
+ {% endblock %} +
+
{% block content %}{% endblock %}
+ +
+

© Copyright 2016 Ape Ask, all rights reserved

+
+ + + + \ No newline at end of file diff --git a/Labs/Lab 9 - Flask/app/templates/login.html b/Labs/Lab 9 - Flask/app/templates/login.html new file mode 100644 index 0000000..8a75cea --- /dev/null +++ b/Labs/Lab 9 - Flask/app/templates/login.html @@ -0,0 +1,18 @@ +{% extends "base.html" %} + +{% block title %} + Login +{% endblock %} + + +{% block content %} +

Hi There! Welcome to Ape Ask, the leading online survey site.

+
+

Let's get you logged in

+
+ + + +
+
+{% endblock %} \ No newline at end of file diff --git a/Labs/Lab 9 - Flask/app/templates/not_authorized.html b/Labs/Lab 9 - Flask/app/templates/not_authorized.html new file mode 100644 index 0000000..0baeb84 --- /dev/null +++ b/Labs/Lab 9 - Flask/app/templates/not_authorized.html @@ -0,0 +1,13 @@ + + + + + Oops! + + +

Uh Oh! You're not authorized

+ +
+ Take me back home, already! + + \ No newline at end of file diff --git a/Labs/Lab 9 - Flask/app/templates/page_not_found.html b/Labs/Lab 9 - Flask/app/templates/page_not_found.html new file mode 100644 index 0000000..2dacddb --- /dev/null +++ b/Labs/Lab 9 - Flask/app/templates/page_not_found.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} + +{% block title %} + Oops! +{% endblock %} + +{% block content %} +

Oh, Pooh Bear! You're stuck because we don't have that page for you.

+ +
+ Go back! +{% endblock %} \ No newline at end of file diff --git a/Labs/Lab 9 - Flask/app/templates/results.html b/Labs/Lab 9 - Flask/app/templates/results.html new file mode 100644 index 0000000..a40bad4 --- /dev/null +++ b/Labs/Lab 9 - Flask/app/templates/results.html @@ -0,0 +1,34 @@ +{% extends "base.html" %} + +{% block title %} + Survey +{% endblock %} + +{% block header %} + {{ super() }} +
+ Logged in as {{ name }} + +
+{% endblock %} + +{% block content %} +

Great news - your results are in! Check it out...

+
+

Here are some of your favorite things

+ Your gender is {{ surveyResponse['gender']}} + Your favorite color is {{ surveyResponse['color']}} + Your favorite food is {{ surveyResponse['food']}} + Your favorite vacation spot is {{ surveyResponse['vacation']}} + Your favorite I School course is {{ surveyResponse['ISchoolClass']}} + +

Wow! Your front end skillz are getting sharp!

+ Before IO Lab, your front end skillz were at a {{ surveyResponse['fe-before']}} + But in just a few short weeks of IO Lab, your front end skillz are now a {{ surveyResponse['fe-after']}} + +
+ Want your survey results emailed to you? + Yes! +
+
+{% endblock %} diff --git a/Labs/Lab 9 - Flask/app/templates/survey.html b/Labs/Lab 9 - Flask/app/templates/survey.html new file mode 100644 index 0000000..35f2d14 --- /dev/null +++ b/Labs/Lab 9 - Flask/app/templates/survey.html @@ -0,0 +1,40 @@ +{% extends "base.html" %} +{% block title %} + Survey +{% endblock %} + + +{% block header %} +{{super()}} +
+ Logged in as {{ name }} + +
+{% endblock %} + +{% block content %} +

A Little Survey About You

+
+

Some of your favorites

+

+ Gender:
+ Male
+ Female
+ Other
+
+ + + + + + +

Let's look at your front end skillz progression

+ + + + +
+{% endblock %} diff --git a/Labs/Lab 9 - Flask/app/views.py b/Labs/Lab 9 - Flask/app/views.py new file mode 100644 index 0000000..eeb5a93 --- /dev/null +++ b/Labs/Lab 9 - Flask/app/views.py @@ -0,0 +1,51 @@ +from app import myapp +from flask import request, render_template, session, redirect, url_for, escape +import os + +myapp.secret_key = os.urandom(24) + +@myapp.route('/') +@myapp.route('/index') +def index(): + username = '' + if 'username' in session: + username = escape(session['username']) + return render_template('survey.html', name=username) + else: + return render_template('login.html') + +@myapp.route('/login', methods=['GET', 'POST']) +def login(): + if request.method=='POST': + session['username']=request.form.get('username') + session['email']=request.form.get('email') + return redirect(url_for('index')) + +@myapp.route('/logout') +def logout(): + session.pop('username', None) + session.pop('email', None) + return redirect(url_for('index')) + +@myapp.route('/submit-survey', methods=['GET', 'POST']) +def submitSurvey(): + username = '' + email = '' + if 'username' in session: + username = escape(session['username']) + email = escape(session['email']) + surveyResponse = {} + surveyResponse['gender'] = request.form.get('gender') + surveyResponse['color'] = request.form.get('color') + surveyResponse['food'] = request.form.get('food') + surveyResponse['vacation'] = request.form.get('vacation') + surveyResponse['ISchoolClass'] = request.form.get('ISchoolClass') + surveyResponse['fe-before'] = request.form.get('feBefore') + surveyResponse['fe-after'] = request.form.get('feAfter') + return render_template('results.html', name=username, email=email, surveyResponse=surveyResponse) + else: + return render_template('login.html') + +@myapp.errorhandler(404) +def page_not_found(error): + return render_template('page_not_found.html'), 404 \ No newline at end of file diff --git a/Labs/Lab 9 - Flask/app/views.pyc b/Labs/Lab 9 - Flask/app/views.pyc new file mode 100644 index 0000000000000000000000000000000000000000..259c8d15006dc6248a0b27530dcff389a33fa068 GIT binary patch literal 2299 zcmcIlOK&4Z5U%cV{79U{&I+`!Aoj2aUpBEo;(%6Ym$2f33>q&8jVxIcPdgcVUQD;c zM#`STPvA#!Z*QJef3p2_-l9jr@#OBaYpOU7QUZj*teJx z{42_caz&9M#cNHOraYi1pu9m*gYqqkwkU5>)TF#cQH%06MQy)3psYhthfIeS+mtlu zN|8}C-QjuBrDSWZVY$h2(xP991^h?5n{91MI+Wms9Xi!8sieE!7VT~J?8@=IjedWl z-@kLVx7pK^J$*|0a`s@OKcFO_@!$b4NZ;Z!P>>vBlV8MDHE8m(g{d|_uZ(qWU*sY& z_0*ZX%3^24ZjH5RS-7^?le9K7Cx%s>P3L9p_$Fg#ab-s7L&%O_IYnEt^z-$_F7MJs$u#*qr7Vk_KHenrh5z0eg%rjwON-4qzkuwz8%! z;@sFBEbOX2Hy4LzF3%jlDu!(cS$Uckq8|iUhBC3Mp~fU2g&meK{A53ebo|BS2i$Kb zCv{N|r^DfJ^0l!`S5}iaGp{G##wU;GS!|aRU^_Wa%`f(_x)8Vp0tVXh`xG=)SM^j+ zdw|3rfipMmtW2z9kG^^NO5FbbyYZ_TpW+W2jxp>@Oo)2{rYTx#s$a+w=m0vL$JaBq z3w)voplERR0jB4rhmh$o3imKe(BiMj<1`ByL_s(d-Y`PmLGcS|&pmVuZphc%04CCX zQ4?JHxYu%SN$=~v>MP4Q9>G?w++AFTFka&Vid<<@>ouTQuLD8^pw$|N0S7RW=tHgm zA2u2Cy}@=(i+~ouMd)z}v>IT{wN{FbwOhBf((72;ysd39 zvaD_2)^;}9ZD>Km9YXg*StAjb@OYO`T&ZBpwmshK`Ng&gTkhJ>WEGDGL#T+GWd zk@`Q6XR+Hfs=4{ffTYH9Ezix<6In@}&CQFsLn-sEu*9=;YKd(3O*5b35` zHyYK{?<@St{E<$7gOf9Mlm|CGAyE$kSOXpbd@yLP(P7!|k>#I|Dn2#SqI78Zt0EDI zl)S>F?1Km}RI!`(en@=A61M&306#xJL literal 0 HcmV?d00001 diff --git a/Labs/Lab 9 - Flask/run.py b/Labs/Lab 9 - Flask/run.py new file mode 100644 index 0000000..dae9904 --- /dev/null +++ b/Labs/Lab 9 - Flask/run.py @@ -0,0 +1,3 @@ +#!flask/bin/python +from app import myapp +myapp.run(debug=True,host='0.0.0.0')