diff --git a/.DS_Store b/.DS_Store index e274363..0b3e8bc 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Rib/.DS_Store b/Rib/.DS_Store new file mode 100644 index 0000000..00eccb3 Binary files /dev/null and b/Rib/.DS_Store differ diff --git a/Rib/ave2.py b/Rib/ave2.py new file mode 100644 index 0000000..4d5644b --- /dev/null +++ b/Rib/ave2.py @@ -0,0 +1,8 @@ +# Average List +# Create a program that prints the average of the values in the list: a = [1, 2, 5, 10, 255, 3] + +print 'For the following list: ' +a = [1, 2, 5, 10, 255, 3] +print a +print 'The average of the values in the list is: ' ,sum(a)/2 + diff --git a/Rib/checker2.py b/Rib/checker2.py new file mode 100644 index 0000000..40eaa43 --- /dev/null +++ b/Rib/checker2.py @@ -0,0 +1,10 @@ +# Assignment: Checkerboard +# Write a program that prints a 'checkerboard' pattern +# to the console. + +def checkerboard(): + + for i in range(4): + print"* * * * " + print" * * * *" +checkerboard() \ No newline at end of file diff --git a/Rib/coins2.py b/Rib/coins2.py new file mode 100644 index 0000000..8859f77 --- /dev/null +++ b/Rib/coins2.py @@ -0,0 +1,21 @@ +# Write a function that simulates tossing a coin 5,000 times. Your function should print how many times the +# head/tail appears. + +import random + +def coin_toss(): + t_count = 0 + h_count = 0 + print "Starting the program..." + for i in range(5000): + random_num = random.randint(0, 1) + if random_num == 0: + t_count += 1 + result = "tail" + else: + h_count += 1 + result = "head" + print "Attempt #" + str(i + 1) + ": Flipping a coin... It's a " + result + "! ... Got " + str(t_count) + " tail(s) so far and " + str(h_count) + " head(s) so far" + print "Ending the program, thank you!" + +coin_toss() \ No newline at end of file diff --git a/Rib/compare2.py b/Rib/compare2.py new file mode 100644 index 0000000..5e3adc5 --- /dev/null +++ b/Rib/compare2.py @@ -0,0 +1,21 @@ +# Write a program that compares two lists and prints a message depending on if the inputs are identical or not. + +# Your program should be able to accept and compare two lists: list_one and list_two. If both lists are identical +# print "The lists are the same". If they are not identical print "The lists are not the same." Try the following test +# cases for lists one and two: + + + +def compare(list1,list2): + if len(list1) != len(list2): + print 'The lists are not the same.' + return False + for i in range(len(list1)): + if list1[i] != list2[i]: + print 'The lists are not the same' + return False + print 'The lists are the same' + +list1 = [1,4,6,7,5,34] +list2 = [2,4,5,7,7,75] +compare(list1,list2) \ No newline at end of file diff --git a/Rib/dict_in2.py b/Rib/dict_in2.py new file mode 100644 index 0000000..0b724c2 --- /dev/null +++ b/Rib/dict_in2.py @@ -0,0 +1,20 @@ +# Assignment: Dictionary in, tuples out +# Write a function that takes in a dictionary and returns a list of tuples where the first tuple item is the key + # and the second is the value. Here's an example: + +a_dict = { + "Speros": "(555) 555-5555", + "Michael": "(999) 999-9999", + "Jay": "(777) 777-7777" +} + + +def my_dict(a_dict): + + print "{}".format(dict.items(a_dict)) + +my_dict(a_dict) + + + + diff --git a/Rib/filter_type2.py b/Rib/filter_type2.py new file mode 100644 index 0000000..7b0a739 --- /dev/null +++ b/Rib/filter_type2.py @@ -0,0 +1,41 @@ +# Assignment: Filter by Type +# Write a program that, given some value, tests that value for its type. Here's what you should do for each type: + +# Integer +# If the integer is greater than or equal to 100, print "That's a big number!" If the integer is less than 100, +# print "That's a small number" + + +# question = 'Please enter an integer from 1 to 100 ' +# print ('Please an integer from 1 to 100,') + + +# a = int(raw_input(question)) + +# if a <= 100=True + +# if True : +# print 'Thats a small number!' +# elif: +# print 'Thats a big number!' +# else: +# print ("That wasnt a number between 1 and 100. Please try again." + +def whatisit(test): + if type(test) is int: + if (test) <= 100: + print "Small Number" + else: + print "Big Number!" + elif type(test) is str: + if len(test) <= 100: + print "Short Sentence" + else: + print "Long Sentence" + elif type(test) is list: + if len(test) <=10: + print "Short List" + else: + print "Big List!" + +whatisit([1,2,43,556,4,5,6,3,2,3,67,8,"sdflk"]) \ No newline at end of file diff --git a/Rib/find2.py b/Rib/find2.py new file mode 100644 index 0000000..e69de29 diff --git a/Rib/find_chr2.py b/Rib/find_chr2.py new file mode 100644 index 0000000..6c73521 --- /dev/null +++ b/Rib/find_chr2.py @@ -0,0 +1,19 @@ +# Assignment: Find Characters +# Write a program that takes a list of strings and a string containing a single character, +# and prints a new list +# of all the strings containing that character. + +def command_F(string_list,char_kb): + new_list = [] + for i in string_list: + if char_kb in i: + new_list.append(i) + print 'This is the new list: ' + print new_list + +words = ['hello','world','my_name', 'is', 'Anna'] +char = 'o' + +command_F(words,char) + + \ No newline at end of file diff --git a/Rib/first2.py b/Rib/first2.py new file mode 100644 index 0000000..cac4b45 --- /dev/null +++ b/Rib/first2.py @@ -0,0 +1,16 @@ +# First and Last +# Print the first and last values in a list like this one: x = ["hello",2,54,-2,7,12,98,"world"]. +# Now create a new list containing only the first and last values in the original list. Your code should work for any list. + +x = ["hello",2,54,-2,7,12,98,"world"] +i=0 +print x[0] + +print 'The first value for the array is : ', x[0] +print 'The last value for the array is : ', x[len(x)-1] + +#Creating a new list containing only the first and last values in the original list. Your code should work for any list. +print 'New List is: ', [x[0], x[-1]] + + + diff --git a/Rib/funwfunc2_odd_even.py b/Rib/funwfunc2_odd_even.py new file mode 100644 index 0000000..30f6caf --- /dev/null +++ b/Rib/funwfunc2_odd_even.py @@ -0,0 +1,11 @@ +# Create a function called odd_even that counts from 1 to 2000. +# As your loop executes have your program print the number of that +# iteration and specify whether it's an odd or even number. + +def odd_even(size): + for x in range(1, size): + if x %2 != 0: + print "The number is {}. This is an odd number.".format(x) + else: + print "The number is {}. This is an even number.".format(x) +odd_even(2000) \ No newline at end of file diff --git a/Rib/hello_flask2/hello.py b/Rib/hello_flask2/hello.py new file mode 100644 index 0000000..eba9f65 --- /dev/null +++ b/Rib/hello_flask2/hello.py @@ -0,0 +1,14 @@ +from flask import Flask, render_template # Import Flask to allow us to create our app. +app = Flask(__name__) + # Global variable __name__ tells Flask whether or not we are running the file + # directly, or importing it as a module. +@app.route('/') +@app.route('/success') +def success(): + return render_template('success.html') # The "@" symbol designates a "decorator" which attaches the following + # function to the '/' route. This means that whenever we send a request to + # localhost:5000/ we will run the following "hello_world" function. +def hello_world(): + return render_template('index.html') + # Return the string 'Hello World!' as a response. +app.run(debug=True) # Run the app in debug mode. diff --git a/Rib/hello_flask2/templates/index.html b/Rib/hello_flask2/templates/index.html new file mode 100644 index 0000000..f401ed9 --- /dev/null +++ b/Rib/hello_flask2/templates/index.html @@ -0,0 +1,12 @@ + + + + + Index Page + + +

Hello Flask!

+

My name is Anna

+ + + \ No newline at end of file diff --git a/Rib/hello_flask2/templates/success.html b/Rib/hello_flask2/templates/success.html new file mode 100644 index 0000000..cd31b59 --- /dev/null +++ b/Rib/hello_flask2/templates/success.html @@ -0,0 +1,10 @@ + + + + + Success Page + + +

You have successfully created another GET route that serves a page!

+ + diff --git a/Rib/min2.py b/Rib/min2.py new file mode 100644 index 0000000..85f562c --- /dev/null +++ b/Rib/min2.py @@ -0,0 +1,7 @@ +# Min and Max +# Print the min and max values in a list like this one: x = [2,54,-2,7,12,98]. Your code should work for any list. +x = [2,54,-2,7,12,98] + +print 'Minimum value for the array is : ', min(x) +print 'Maximum value for the array is : ', max(x) + diff --git a/Rib/mult_sum_ave2/ave2.py b/Rib/mult_sum_ave2/ave2.py new file mode 100644 index 0000000..4d5644b --- /dev/null +++ b/Rib/mult_sum_ave2/ave2.py @@ -0,0 +1,8 @@ +# Average List +# Create a program that prints the average of the values in the list: a = [1, 2, 5, 10, 255, 3] + +print 'For the following list: ' +a = [1, 2, 5, 10, 255, 3] +print a +print 'The average of the values in the list is: ' ,sum(a)/2 + diff --git a/Rib/mult_sum_ave2/multi_1.py b/Rib/mult_sum_ave2/multi_1.py new file mode 100644 index 0000000..5b14fa2 --- /dev/null +++ b/Rib/mult_sum_ave2/multi_1.py @@ -0,0 +1,18 @@ +# Multiples +# Part I - Write code that prints all the odd numbers from 1 to 1000. Use the for loop and don't use a list to do +# this exercise. + +for x in range(1, 1001): + if (x % 3 == 0): + print x + +# Multiples +# Part II - Create another program that prints all the multiples of 5 from 5 to 1,000,000.: +sum = 1 + +for i in range(5, 1000000): + if i % 5 % 1000000 == 0: + sum += i + +print("The sum of multiples of 5 between 5 to 1000000 is: " , + sum) + diff --git a/Rib/mult_sum_ave2/sums2.py b/Rib/mult_sum_ave2/sums2.py new file mode 100644 index 0000000..feb8d97 --- /dev/null +++ b/Rib/mult_sum_ave2/sums2.py @@ -0,0 +1,9 @@ +# Sum List +# Create a program that prints the sum of all the values in the list: a = [1, 2, 5, 10, 255, 3] + +print 'For the following list: ' +a = [1, 2, 5, 10, 255, 3] +print a +print 'The sum of the list is: ', sum(a) + + diff --git a/Rib/multiply2.py b/Rib/multiply2.py new file mode 100644 index 0000000..1c3665f --- /dev/null +++ b/Rib/multiply2.py @@ -0,0 +1,22 @@ +# Multiply: +# Create a function called 'multiply' that iterates through each value in a list (e.g. a = [2, 4, 10, 16]) +# and returns a list where each value has been multiplied by 5. The function should multiply each value in the +# list by the second argument. For example, let's say: + +# a = [2,4,10,16] + +# Then: + +# b = multiply(a, 5) +# print b + +# Should print [10, 20, 50, 80 ]. + +def multiply(list): + new_list = [] + for i in list: + new_list += [i*5] + if i >= len(list): + print new_list + +multiply([1,2,3,4]) \ No newline at end of file diff --git a/Rib/names2.py b/Rib/names2.py new file mode 100644 index 0000000..f75a11f --- /dev/null +++ b/Rib/names2.py @@ -0,0 +1,125 @@ +# Assignment: Names +# Write the following function. + +# students = [{'first_name': 'Michael', 'last_name' : 'Jordan'}, +# {'first_name' : 'John', 'last_name' : 'Rosales'}, +# {'first_name' : 'Mark', 'last_name' : 'Guillen'}, +# {'first_name' : 'KB', 'last_name' : 'Tonel'}] + +users = { + 'Students': [ + {'first_name': 'Michael', 'last_name' : 'Jordan'}, + {'first_name' : 'John', 'last_name' : 'Rosales'}, + {'first_name' : 'Mark', 'last_name' : 'Guillen'}, + {'first_name' : 'KB', 'last_name' : 'Tonel'} + ], + + 'Instructors': [ + {'first_name' : 'Michael', 'last_name' : 'Choi'}, + {'first_name' : 'Martin', 'last_name' : 'Puryear'} + ] + } + +students = users['Students'] +# print students +# print green['first_name'], green['last_name'] + +for student in students: + print student['first_name'], student['last_name'] + +instructors = users['Instructors'] + +for instructor in instructors: + print instructor['first_name'], instructor['last_name'] + +# + + + + + + +# green = students[0] + +# # print "green: " ,green['first_name'] +# # print "green: " ,green['last_name'] + +# green2 = students[1] +# # print "green2: " ,green2 +# # print "green2: " ,green2['first_name'] +# # print "green2: " ,green2['last_name'] + +# green3 = students[2] +# # print "green3: " ,green3 +# # print "green3: " ,green3['first_name'] +# # print "green3: " ,green3['last_name'] + +# green4 = students[3] +# # print "green4: " ,green4 +# # print "green4: " ,green4['first_name'] +# # print "green4: " ,green4['last_name'] + +# for green in students: +# print "first_name: ",green['first_name'], "last_name: ", green['last_name'] +# # ['first_name'],['last_name'] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# def output(students): + +# for x in students: +# print x['first_name'], x['last_name'] + +# def all(users): +# for role in users: +# count = 0 +# print role +# for people in users[role]: +# count += 1 +# length = len(people['first_name']) + len(people['last_name']) +# print "{} - {} {} - {}".format(count, people['first_name'], people['last_name'], length) + +# output(students) +# all(users) + + + + + + + + + + diff --git a/Rib/score_grades2.py b/Rib/score_grades2.py new file mode 100644 index 0000000..ee695e3 --- /dev/null +++ b/Rib/score_grades2.py @@ -0,0 +1,18 @@ +import random + +def grading(): + print "Score and Grades" + for i in range(10): + random_num = random.randint(60, 100) + if random_num > 89: + letter_grade = "A" + elif random_num > 79: + letter_grade = "B" + elif random_num > 69: + letter_grade = "C" + else: + letter_grade = "D" + print "Score: " + str(random_num) + "; Your grade is: " + letter_grade + print "End of the Program. Bye!" + +grading() \ No newline at end of file diff --git a/Rib/stars2.py b/Rib/stars2.py new file mode 100644 index 0000000..9e9e287 --- /dev/null +++ b/Rib/stars2.py @@ -0,0 +1,33 @@ +# Assignment: Stars +# Write the following functions. +# Part I +# Create a function called draw_stars() that takes a list of numbers and prints out *. + +# For example: + +# x = [4, 6, 1, 3, 5, 7, 25] +# Copy +# draw_stars(x)should print the following in when invoked: + +# **** +# ****** +# * +# *** +# ***** +# ******* +# ************************* +def draw_stars(list): + for i in range(len(list)): + print "* " * list[i] + + +def draw_stars2(list): + for i in range(len(list)): + if type(list[i]) == int: + print "*" * list[i] + elif type(list[i]) == str: + print list[i][0].lower() * len(list[i]) + +test_list = [4, "Tom", 1, "Michael", 5, 7, "Jimmy Smith"] +draw_stars2(test_list) + diff --git a/Rib/string_list_practice/find2.py b/Rib/string_list_practice/find2.py new file mode 100644 index 0000000..e806e9f --- /dev/null +++ b/Rib/string_list_practice/find2.py @@ -0,0 +1,16 @@ +#Find and Replace +# In this string: words = "It's thanksgiving day. It's my birthday,too!" print the position of the first instance +# of the word "day". Then create a new string where the word "day" is replaced with the word "month". + +words = "It's thanksgiving day. It's my birthday,too!" +print words.find('day') + +#creating a new string where the word , "day", is replaced with the word, "month'" + +print words.replace('day', 'month') + + + + + + diff --git a/Rib/string_list_practice/first2.py b/Rib/string_list_practice/first2.py new file mode 100644 index 0000000..cac4b45 --- /dev/null +++ b/Rib/string_list_practice/first2.py @@ -0,0 +1,16 @@ +# First and Last +# Print the first and last values in a list like this one: x = ["hello",2,54,-2,7,12,98,"world"]. +# Now create a new list containing only the first and last values in the original list. Your code should work for any list. + +x = ["hello",2,54,-2,7,12,98,"world"] +i=0 +print x[0] + +print 'The first value for the array is : ', x[0] +print 'The last value for the array is : ', x[len(x)-1] + +#Creating a new list containing only the first and last values in the original list. Your code should work for any list. +print 'New List is: ', [x[0], x[-1]] + + + diff --git a/Rib/string_list_practice/min2.py b/Rib/string_list_practice/min2.py new file mode 100644 index 0000000..85f562c --- /dev/null +++ b/Rib/string_list_practice/min2.py @@ -0,0 +1,7 @@ +# Min and Max +# Print the min and max values in a list like this one: x = [2,54,-2,7,12,98]. Your code should work for any list. +x = [2,54,-2,7,12,98] + +print 'Minimum value for the array is : ', min(x) +print 'Maximum value for the array is : ', max(x) + diff --git a/Rib/sums2.py b/Rib/sums2.py new file mode 100644 index 0000000..feb8d97 --- /dev/null +++ b/Rib/sums2.py @@ -0,0 +1,9 @@ +# Sum List +# Create a program that prints the sum of all the values in the list: a = [1, 2, 5, 10, 255, 3] + +print 'For the following list: ' +a = [1, 2, 5, 10, 255, 3] +print a +print 'The sum of the list is: ', sum(a) + + diff --git a/Rib/type_list2.py b/Rib/type_list2.py new file mode 100644 index 0000000..93781fb --- /dev/null +++ b/Rib/type_list2.py @@ -0,0 +1,42 @@ +# Assignment: Type List +# Write a program that takes a list and prints a message +# for each element in the list, based on that element's +# ta type. + +# Your program input will always be a list. For each item in the list, test its data type. If the item is a string, +# concatenate it onto a new string. If it is a number, add it to a running sum. At the end of your program print +# the string, the number and an analysis of what the array contains. If it contains only one type, print that type, +# otherwise, print 'mixed'. + +# Here are a couple of test cases. Think of some of your own, too. What kind of unexpected input could you get? + + +def whatisit(list): + string = '' + sum = 0 + + + for item in list: + if type(item) is int or type(item) is float: + sum += item + elif type(item) is str: + string += ''+ item + + if len(string) > 0 and sum > 0: + print 'The array you entered is of mixed type' + print string + print sum + + elif len(string) == 0 and sum > 0: + print 'The array you entered is of integer type' + print sum + + elif len(string) > 0 and sum == 0: + print 'The array you entered is of string type' + print string + +whatisit(['magical unicorns',19,'hello',98.98,'world']) +whatisit ([2,3,1,7,4,12]) +whatisit (['magical','unicorns']) + + diff --git a/matt_tucker/.DS_Store b/matt_tucker/.DS_Store new file mode 100644 index 0000000..b3bc1da Binary files /dev/null and b/matt_tucker/.DS_Store differ diff --git a/rib/blogs2.mwb b/rib/blogs2.mwb new file mode 100644 index 0000000..2ac778c Binary files /dev/null and b/rib/blogs2.mwb differ diff --git a/rib/books2.mwb b/rib/books2.mwb new file mode 100644 index 0000000..540818c Binary files /dev/null and b/rib/books2.mwb differ diff --git a/rib/disappearing_ninjas_flask/.DS_Store b/rib/disappearing_ninjas_flask/.DS_Store new file mode 100644 index 0000000..1feff79 Binary files /dev/null and b/rib/disappearing_ninjas_flask/.DS_Store differ diff --git a/rib/disappearing_ninjas_flask/server.py b/rib/disappearing_ninjas_flask/server.py new file mode 100644 index 0000000..151d80e --- /dev/null +++ b/rib/disappearing_ninjas_flask/server.py @@ -0,0 +1,23 @@ +from flask import Flask, render_template, request, url_for # Import Flask to allow us to create our app. +app = Flask(__name__) # Global variable __name__ tells Flask whether or not we are running the file + # directly, or importing it as a module. +@app.route('/') +def index(): + return render_template('index.html') + # Return the string 'Hello World!' as a response. + +@app.route('/ninja') # The "@" symbol designates a "decorator" which attaches the following +def show_ninja(): + return render_template('ninja.html') + +@app.route('/ninja/') +def ninja(color): + if color.lower() in ['red', 'blue', 'purple', 'orange']: + image = color + '.jpg' + else: + image = 'notapril.jpg' + + return render_template('blue.html', image=image) + + +app.run(debug=True) \ No newline at end of file diff --git a/rib/disappearing_ninjas_flask/static/.DS_Store b/rib/disappearing_ninjas_flask/static/.DS_Store new file mode 100644 index 0000000..940e942 Binary files /dev/null and b/rib/disappearing_ninjas_flask/static/.DS_Store differ diff --git a/rib/disappearing_ninjas_flask/static/img/blue.jpg b/rib/disappearing_ninjas_flask/static/img/blue.jpg new file mode 100755 index 0000000..c049cfd Binary files /dev/null and b/rib/disappearing_ninjas_flask/static/img/blue.jpg differ diff --git a/rib/disappearing_ninjas_flask/static/img/notapril.jpg b/rib/disappearing_ninjas_flask/static/img/notapril.jpg new file mode 100755 index 0000000..39b2f0a Binary files /dev/null and b/rib/disappearing_ninjas_flask/static/img/notapril.jpg differ diff --git a/rib/disappearing_ninjas_flask/static/img/orange.jpg b/rib/disappearing_ninjas_flask/static/img/orange.jpg new file mode 100755 index 0000000..4ad75d0 Binary files /dev/null and b/rib/disappearing_ninjas_flask/static/img/orange.jpg differ diff --git a/rib/disappearing_ninjas_flask/static/img/purple.jpg b/rib/disappearing_ninjas_flask/static/img/purple.jpg new file mode 100755 index 0000000..8912292 Binary files /dev/null and b/rib/disappearing_ninjas_flask/static/img/purple.jpg differ diff --git a/rib/disappearing_ninjas_flask/static/img/red.jpg b/rib/disappearing_ninjas_flask/static/img/red.jpg new file mode 100755 index 0000000..57fb2a3 Binary files /dev/null and b/rib/disappearing_ninjas_flask/static/img/red.jpg differ diff --git a/rib/disappearing_ninjas_flask/static/img/tmnt.png b/rib/disappearing_ninjas_flask/static/img/tmnt.png new file mode 100644 index 0000000..941c82e Binary files /dev/null and b/rib/disappearing_ninjas_flask/static/img/tmnt.png differ diff --git a/rib/disappearing_ninjas_flask/static/style_sheet.css b/rib/disappearing_ninjas_flask/static/style_sheet.css new file mode 100644 index 0000000..f5f2e11 --- /dev/null +++ b/rib/disappearing_ninjas_flask/static/style_sheet.css @@ -0,0 +1,3 @@ +h1{ + color: blue; +} diff --git a/rib/disappearing_ninjas_flask/templates/blue.html b/rib/disappearing_ninjas_flask/templates/blue.html new file mode 100644 index 0000000..4ab70a1 --- /dev/null +++ b/rib/disappearing_ninjas_flask/templates/blue.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/rib/disappearing_ninjas_flask/templates/else.html b/rib/disappearing_ninjas_flask/templates/else.html new file mode 100644 index 0000000..b611132 --- /dev/null +++ b/rib/disappearing_ninjas_flask/templates/else.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/rib/disappearing_ninjas_flask/templates/index.html b/rib/disappearing_ninjas_flask/templates/index.html new file mode 100644 index 0000000..1983cc9 --- /dev/null +++ b/rib/disappearing_ninjas_flask/templates/index.html @@ -0,0 +1,12 @@ + + + + Index Page + + + + +

No Ninjas Here!

+ + + \ No newline at end of file diff --git a/rib/disappearing_ninjas_flask/templates/ninja.html b/rib/disappearing_ninjas_flask/templates/ninja.html new file mode 100644 index 0000000..70ed1a7 --- /dev/null +++ b/rib/disappearing_ninjas_flask/templates/ninja.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/rib/disappearing_ninjas_flask/templates/orange.html b/rib/disappearing_ninjas_flask/templates/orange.html new file mode 100644 index 0000000..8f6c7fd --- /dev/null +++ b/rib/disappearing_ninjas_flask/templates/orange.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/rib/disappearing_ninjas_flask/templates/purple.html b/rib/disappearing_ninjas_flask/templates/purple.html new file mode 100644 index 0000000..1a4d46f --- /dev/null +++ b/rib/disappearing_ninjas_flask/templates/purple.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/rib/disappearing_ninjas_flask/templates/red.html b/rib/disappearing_ninjas_flask/templates/red.html new file mode 100644 index 0000000..851c785 --- /dev/null +++ b/rib/disappearing_ninjas_flask/templates/red.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/rib/facebook.mwb b/rib/facebook.mwb new file mode 100644 index 0000000..cdd6c25 Binary files /dev/null and b/rib/facebook.mwb differ diff --git a/rib/friends2/friends2.mwb b/rib/friends2/friends2.mwb new file mode 100644 index 0000000..db15c0a Binary files /dev/null and b/rib/friends2/friends2.mwb differ diff --git a/rib/friends2/mysqlconnection.py b/rib/friends2/mysqlconnection.py new file mode 100644 index 0000000..6b78aa6 --- /dev/null +++ b/rib/friends2/mysqlconnection.py @@ -0,0 +1,39 @@ +from flask_sqlalchemy import SQLAlchemy +from sqlalchemy.sql import text +# Create a class that will give us an object that we can use to connect to a database +class MySQLConnection(object): + def __init__(self, app, db): + config = { + 'host': 'localhost', + 'database': db, # we got db as an argument + 'user': 'root', + 'password': 'root', + 'port': '8889' # change the port to match the port your SQL server is running on + } + # this will use the above values to generate the path to connect to your sql database + DATABASE_URI = "mysql://{}:{}@127.0.0.1:{}/{}".format(config['user'], config['password'], config['port'], config['database']) + app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI + app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True + # establish the connection to database + self.db = SQLAlchemy(app) + # this is the method we will use to query the database + def query_db(self, query, data=None): + result = self.db.session.execute(text(query), data) + if query[0:6].lower() == 'select': + # if the query was a select + # convert the result to a list of dictionaries + list_result = [dict(r) for r in result] + # return the results as a list of dictionaries + return list_result + elif query[0:6].lower() == 'insert': + # if the query was an insert, return the id of the + # commit changes + self.db.session.commit() + # row that was inserted + return result.lastrowid + else: + # if the query was an update or delete, return nothing and commit changes + self.db.session.commit() +# This is the module method to be called by the user in server.py. Make sure to provide the db name! +def MySQLConnector(app, db): + return MySQLConnection(app, db) diff --git a/rib/friends2/server.py b/rib/friends2/server.py new file mode 100644 index 0000000..dfb7d69 --- /dev/null +++ b/rib/friends2/server.py @@ -0,0 +1,50 @@ +from flask import Flask, request, redirect, render_template, session, flash +from mysqlconnection import MySQLConnector +app = Flask(__name__) +mysql = MySQLConnector(app,'friendsdb') + +# @app.route('/friends/') +# def show(friend_id): +# #Write a query to select specific user by id. At tevey point where +# #we want to insert data, we write ':' and variable name. +# query = 'SELECT * FROM friends WHERE id= :specifc_id' +# #Then define a dictionary with key that matches :variable_name in query. +# data = {'specific_id': friend_id} +# #Run query with inserted data +# friends = mysql.query_db(query, data) +# #Friends should be a list with a single object, +# #so we pass the value at [0] to our template under alias one_friend +# return render_template('index.html', one_friend= friends[0]) + +@app.route('/') +def index(): + return render_template('index.html') + query = 'SEECT * FROM friends' #defines my query + friends = mysql.query_db('SELECT * FROM friends') #runs query_db() + print friends + return render_template('index.html', all_friends=friends) #pass data to our template + + +@app.route('/friends', methods=['POST']) +def create(): + # add a friend to the database! + query = 'INSERT NTO friends(first_name, last_name, occupation created_at, updated_at)VALUES(first_name,last_name,:occupation, NOW(),NOW())' + + data = { + 'first_name': request.form['first_name'], + 'last_name': request.form['last_name'], + 'occupation': request.form['occupation'] + } + print request.form['first_name'] + print request.form['last_name'] + print request.form['occupation'] + mySQL.query_db(query, data) + return redirect('/') + +@app.route('/remove_friend/', methods=['POST']) +def delete(friend_id): + query = "DELETE FROM friends WHERE id = :id" + data = {'id': friend_id} + mysql.query_db(query, data) + return redirect('/') +app.run(debug=True) \ No newline at end of file diff --git a/rib/friends2/templates/index.html b/rib/friends2/templates/index.html new file mode 100644 index 0000000..5f50ddb --- /dev/null +++ b/rib/friends2/templates/index.html @@ -0,0 +1,31 @@ + + + + Friends + + + +{{ all_friends }} +

Theses are all my friends!

+ +{% for friend in all_friends: %} +

ID: {{ friend['id'] }}

+

First Name: {{ friend['first_name'] }}

+

Last Name: {{ friend['last_name'] }}

+

Occupation: {{ friend['occupation'] }}

+
+{% endfor %} +

First Name: Jimmy

+

Last Name: June

+

Occupation: Instructor

+
+

Add a Friend

+
+ + + + +
+ + + \ No newline at end of file diff --git a/rib/hello_world2/apps/__init__.py b/rib/hello_world2/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/hello_world2/apps/hello_world2_app/__init__.py b/rib/hello_world2/apps/hello_world2_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/hello_world2/apps/hello_world2_app/admin.py b/rib/hello_world2/apps/hello_world2_app/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/rib/hello_world2/apps/hello_world2_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/rib/hello_world2/apps/hello_world2_app/apps.py b/rib/hello_world2/apps/hello_world2_app/apps.py new file mode 100644 index 0000000..42004d5 --- /dev/null +++ b/rib/hello_world2/apps/hello_world2_app/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class HelloWorld2AppConfig(AppConfig): + name = 'hello_world2_app' diff --git a/rib/hello_world2/apps/hello_world2_app/migrations/__init__.py b/rib/hello_world2/apps/hello_world2_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/hello_world2/apps/hello_world2_app/models.py b/rib/hello_world2/apps/hello_world2_app/models.py new file mode 100644 index 0000000..bd4b2ab --- /dev/null +++ b/rib/hello_world2/apps/hello_world2_app/models.py @@ -0,0 +1,5 @@ +from __future__ import unicode_literals + +from django.db import models + +# Create your models here. diff --git a/rib/hello_world2/apps/hello_world2_app/templates/hello_world2_app/index.html b/rib/hello_world2/apps/hello_world2_app/templates/hello_world2_app/index.html new file mode 100644 index 0000000..090d0ba --- /dev/null +++ b/rib/hello_world2/apps/hello_world2_app/templates/hello_world2_app/index.html @@ -0,0 +1,9 @@ + + + + Index Page + + +

Hello World!

+ + \ No newline at end of file diff --git a/rib/hello_world2/apps/hello_world2_app/tests.py b/rib/hello_world2/apps/hello_world2_app/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/rib/hello_world2/apps/hello_world2_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/rib/hello_world2/apps/hello_world2_app/urls.py b/rib/hello_world2/apps/hello_world2_app/urls.py new file mode 100644 index 0000000..c5b5858 --- /dev/null +++ b/rib/hello_world2/apps/hello_world2_app/urls.py @@ -0,0 +1,6 @@ +from django.conf.urls import url +from . import views + +urlpatterns = [ + url(r'^$', views.index) +] \ No newline at end of file diff --git a/rib/hello_world2/apps/hello_world2_app/views.py b/rib/hello_world2/apps/hello_world2_app/views.py new file mode 100644 index 0000000..379ab26 --- /dev/null +++ b/rib/hello_world2/apps/hello_world2_app/views.py @@ -0,0 +1,5 @@ +from django.shortcuts import render + +def index(request): + print "This is inseide the index method" + return render(request, 'hello_world2_app/index.html') diff --git a/rib/hello_world2/db.sqlite3 b/rib/hello_world2/db.sqlite3 new file mode 100644 index 0000000..c6daae8 Binary files /dev/null and b/rib/hello_world2/db.sqlite3 differ diff --git a/rib/hello_world2/hello_world2/__init__.py b/rib/hello_world2/hello_world2/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/hello_world2/hello_world2/settings.py b/rib/hello_world2/hello_world2/settings.py new file mode 100644 index 0000000..bc95658 --- /dev/null +++ b/rib/hello_world2/hello_world2/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for hello_world2 project. + +Generated by 'django-admin startproject' using Django 1.10.6. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.10/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'r_!e44hc6a=#bxywz*qtx50tazmg^l+fxlusfxses+6$u4ty=%' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'apps.hello_world2_app', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'hello_world2.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'hello_world2.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/1.10/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.10/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/rib/hello_world2/hello_world2/urls.py b/rib/hello_world2/hello_world2/urls.py new file mode 100644 index 0000000..fbbe867 --- /dev/null +++ b/rib/hello_world2/hello_world2/urls.py @@ -0,0 +1,21 @@ +"""hello_world2 URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url, include +from django.contrib import admin + +urlpatterns = [ + url(r'^', include('apps.hello_world2_app.urls')), +] diff --git a/rib/hello_world2/hello_world2/wsgi.py b/rib/hello_world2/hello_world2/wsgi.py new file mode 100644 index 0000000..07c391b --- /dev/null +++ b/rib/hello_world2/hello_world2/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for hello_world2 project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hello_world2.settings") + +application = get_wsgi_application() diff --git a/rib/hello_world2/manage.py b/rib/hello_world2/manage.py new file mode 100755 index 0000000..f17b0aa --- /dev/null +++ b/rib/hello_world2/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hello_world2.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) + raise + execute_from_command_line(sys.argv) diff --git a/rib/landing_page/server.py b/rib/landing_page/server.py new file mode 100644 index 0000000..00e013c --- /dev/null +++ b/rib/landing_page/server.py @@ -0,0 +1,18 @@ +from flask import Flask, render_template # Import Flask to allow us to create our app. +app = Flask(__name__) + # Global variable __name__ tells Flask whether or not we are running the file + # directly, or importing it as a module. +@app.route('/') +def hello_world(): + return render_template('index.html') + # Return the string 'Hello World!' as a response. +@app.route('/ninjas') +def ninjas(): + return render_template('ninjas.html') + +@app.route('/dojos/new') +def dojo_new(): + return render_template('dojo_new.html') + # function to the '/' route. This means that whenever we send a request to + # localhost:5000/ we will run the following "hello_world" function. +app.run(debug=True) # Run the app in debug mode. \ No newline at end of file diff --git a/rib/landing_page/static/style.css b/rib/landing_page/static/style.css new file mode 100644 index 0000000..6694786 --- /dev/null +++ b/rib/landing_page/static/style.css @@ -0,0 +1,3 @@ +body{ + background-color: blue; +} \ No newline at end of file diff --git a/rib/landing_page/templates/dojo_new.html b/rib/landing_page/templates/dojo_new.html new file mode 100644 index 0000000..1600942 --- /dev/null +++ b/rib/landing_page/templates/dojo_new.html @@ -0,0 +1,20 @@ + + + + + + + + +
+ First name:
+
+ Last name:
+ +
+ + +
+ + + \ No newline at end of file diff --git a/rib/landing_page/templates/index.html b/rib/landing_page/templates/index.html new file mode 100644 index 0000000..bdae6e7 --- /dev/null +++ b/rib/landing_page/templates/index.html @@ -0,0 +1,12 @@ + + + + + + Index Page + + +

Landing Page

+ + + \ No newline at end of file diff --git a/rib/landing_page/templates/ninjas.html b/rib/landing_page/templates/ninjas.html new file mode 100644 index 0000000..cee0527 --- /dev/null +++ b/rib/landing_page/templates/ninjas.html @@ -0,0 +1,11 @@ + + + + + Ninjas + + +

Ninjas

+ + + \ No newline at end of file diff --git a/rib/portfolio2/apps/__init__.py b/rib/portfolio2/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/portfolio2/apps/portfolio2_app/__init__.py b/rib/portfolio2/apps/portfolio2_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/portfolio2/apps/portfolio2_app/admin.py b/rib/portfolio2/apps/portfolio2_app/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/rib/portfolio2/apps/portfolio2_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/rib/portfolio2/apps/portfolio2_app/apps.py b/rib/portfolio2/apps/portfolio2_app/apps.py new file mode 100644 index 0000000..20d21a3 --- /dev/null +++ b/rib/portfolio2/apps/portfolio2_app/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class Portfolio2AppConfig(AppConfig): + name = 'portfolio2_app' diff --git a/rib/portfolio2/apps/portfolio2_app/migrations/__init__.py b/rib/portfolio2/apps/portfolio2_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/portfolio2/apps/portfolio2_app/models.py b/rib/portfolio2/apps/portfolio2_app/models.py new file mode 100644 index 0000000..bd4b2ab --- /dev/null +++ b/rib/portfolio2/apps/portfolio2_app/models.py @@ -0,0 +1,5 @@ +from __future__ import unicode_literals + +from django.db import models + +# Create your models here. diff --git a/rib/portfolio2/apps/portfolio2_app/templates/portfolio2_app/index.html b/rib/portfolio2/apps/portfolio2_app/templates/portfolio2_app/index.html new file mode 100644 index 0000000..49041f8 --- /dev/null +++ b/rib/portfolio2/apps/portfolio2_app/templates/portfolio2_app/index.html @@ -0,0 +1,9 @@ + + + + Index Page + + +

Welcome to My Portfolio

+ + \ No newline at end of file diff --git a/rib/portfolio2/apps/portfolio2_app/templates/portfolio2_app/testimonials.html b/rib/portfolio2/apps/portfolio2_app/templates/portfolio2_app/testimonials.html new file mode 100644 index 0000000..43caf11 --- /dev/null +++ b/rib/portfolio2/apps/portfolio2_app/templates/portfolio2_app/testimonials.html @@ -0,0 +1,11 @@ + + + + Testimonials + + +

Testimonials

+

"The best money I ever spent was hiring Rib to create my website!"

+

"Rib's projects make the world a better place"

+ + \ No newline at end of file diff --git a/rib/portfolio2/apps/portfolio2_app/tests.py b/rib/portfolio2/apps/portfolio2_app/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/rib/portfolio2/apps/portfolio2_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/rib/portfolio2/apps/portfolio2_app/urls.py b/rib/portfolio2/apps/portfolio2_app/urls.py new file mode 100644 index 0000000..22d9552 --- /dev/null +++ b/rib/portfolio2/apps/portfolio2_app/urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import url +from . import views + +urlpatterns = [ + url(r'^$', views.index), + url(r'^testimonials$', views.testimonials) +] diff --git a/rib/portfolio2/apps/portfolio2_app/views.py b/rib/portfolio2/apps/portfolio2_app/views.py new file mode 100644 index 0000000..b4bcfee --- /dev/null +++ b/rib/portfolio2/apps/portfolio2_app/views.py @@ -0,0 +1,11 @@ +from django.shortcuts import render + +def index(request): + print "Inside the index method" + + return render(request, 'portfolio2_app/index.html') + +def testimonials(request): + print "Inside the testimonials method" + + return render(request, 'portfolio2_app/testimonials.html') diff --git a/rib/portfolio2/db.sqlite3 b/rib/portfolio2/db.sqlite3 new file mode 100644 index 0000000..00c4dcb Binary files /dev/null and b/rib/portfolio2/db.sqlite3 differ diff --git a/rib/portfolio2/main/__init__.py b/rib/portfolio2/main/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/portfolio2/main/settings.py b/rib/portfolio2/main/settings.py new file mode 100644 index 0000000..89dccd5 --- /dev/null +++ b/rib/portfolio2/main/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for main project. + +Generated by 'django-admin startproject' using Django 1.10.6. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.10/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '3jt&jxv1lz(-gum+mpgc(dy80m!0!0!(j0-=9u19b&d=gq(0l6' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'apps.portfolio2_app', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'main.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'main.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/1.10/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.10/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/rib/portfolio2/main/urls.py b/rib/portfolio2/main/urls.py new file mode 100644 index 0000000..e56d9d7 --- /dev/null +++ b/rib/portfolio2/main/urls.py @@ -0,0 +1,21 @@ +"""main URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url, include +from django.contrib import admin + +urlpatterns = [ + url(r'^', include('apps.portfolio2_app.urls')) +] diff --git a/rib/portfolio2/main/wsgi.py b/rib/portfolio2/main/wsgi.py new file mode 100644 index 0000000..4d1e3f4 --- /dev/null +++ b/rib/portfolio2/main/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for main project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + +application = get_wsgi_application() diff --git a/rib/portfolio2/manage.py b/rib/portfolio2/manage.py new file mode 100755 index 0000000..ad5d3e7 --- /dev/null +++ b/rib/portfolio2/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) + raise + execute_from_command_line(sys.argv) diff --git a/rib/survey4/apps/__init__.py b/rib/survey4/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/survey4/apps/survey4_app/__init__.py b/rib/survey4/apps/survey4_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/survey4/apps/survey4_app/admin.py b/rib/survey4/apps/survey4_app/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/rib/survey4/apps/survey4_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/rib/survey4/apps/survey4_app/apps.py b/rib/survey4/apps/survey4_app/apps.py new file mode 100644 index 0000000..d0a163d --- /dev/null +++ b/rib/survey4/apps/survey4_app/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class Survey4AppConfig(AppConfig): + name = 'survey4_app' diff --git a/rib/survey4/apps/survey4_app/migrations/__init__.py b/rib/survey4/apps/survey4_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/survey4/apps/survey4_app/models.py b/rib/survey4/apps/survey4_app/models.py new file mode 100644 index 0000000..bd4b2ab --- /dev/null +++ b/rib/survey4/apps/survey4_app/models.py @@ -0,0 +1,5 @@ +from __future__ import unicode_literals + +from django.db import models + +# Create your models here. diff --git a/rib/survey4/apps/survey4_app/templates/survey4_app/index.html b/rib/survey4/apps/survey4_app/templates/survey4_app/index.html new file mode 100644 index 0000000..987e55a --- /dev/null +++ b/rib/survey4/apps/survey4_app/templates/survey4_app/index.html @@ -0,0 +1,34 @@ + + + + Survey Form + + +
+ {% csrf_token %} + +
+ + +

+ + +

+
+
+ + +
+ + + \ No newline at end of file diff --git a/rib/survey4/apps/survey4_app/templates/survey4_app/results.html b/rib/survey4/apps/survey4_app/templates/survey4_app/results.html new file mode 100644 index 0000000..b4408f7 --- /dev/null +++ b/rib/survey4/apps/survey4_app/templates/survey4_app/results.html @@ -0,0 +1,16 @@ + + + + Survey Form + + +

Thanks for submitting this form! You have submitted this form {{request.session.counter}} now.

+

Submitted Information

+

Name: {{request.session.name}}

+

Dojo Location: {{request.session.location}}

+

Favorite Language: {{request.session.language}}

+

Comment: {{request.session.comment}}

+ + Go Back + + \ No newline at end of file diff --git a/rib/survey4/apps/survey4_app/tests.py b/rib/survey4/apps/survey4_app/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/rib/survey4/apps/survey4_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/rib/survey4/apps/survey4_app/urls.py b/rib/survey4/apps/survey4_app/urls.py new file mode 100644 index 0000000..b659ed7 --- /dev/null +++ b/rib/survey4/apps/survey4_app/urls.py @@ -0,0 +1,8 @@ +from django.conf.urls import url +from . import views + +urlpatterns = [ + url(r'^$', views.index), + url(r'^results$', views.results), + url(r'^process$', views.process) +] \ No newline at end of file diff --git a/rib/survey4/apps/survey4_app/views.py b/rib/survey4/apps/survey4_app/views.py new file mode 100644 index 0000000..ce617b4 --- /dev/null +++ b/rib/survey4/apps/survey4_app/views.py @@ -0,0 +1,26 @@ +from django.shortcuts import render, redirect + +def index(request): + print "Inside the index method" + if 'counter' not in request.session: + request.session['counter'] = 0 + + return render(request, 'survey4_app/index.html') + +def process(request): + print "Inside the process method" + request.session['counter'] += 1 + if request.method == "POST": + request.session['name'] = request.POST['name'] + request.session['location'] = request.POST['location'] + request.session['language'] = request.POST['language'] + request.session['comment'] = request.POST['comment'] + return redirect('/results') + + return redirect('/') +def results(request): + print "Inside the results method" + + return render(request, 'survey4_app/results.html') + + diff --git a/rib/survey4/db.sqlite3 b/rib/survey4/db.sqlite3 new file mode 100644 index 0000000..525fbee Binary files /dev/null and b/rib/survey4/db.sqlite3 differ diff --git a/rib/survey4/main/__init__.py b/rib/survey4/main/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/survey4/main/settings.py b/rib/survey4/main/settings.py new file mode 100644 index 0000000..085e876 --- /dev/null +++ b/rib/survey4/main/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for main project. + +Generated by 'django-admin startproject' using Django 1.10.6. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.10/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'e@yc1(c!5z#08(zkza^kv!!x3@o=f-x&m+8(q%_(=b-fya3v8t' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'apps.survey4_app', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'main.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'main.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/1.10/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.10/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/rib/survey4/main/urls.py b/rib/survey4/main/urls.py new file mode 100644 index 0000000..359bda4 --- /dev/null +++ b/rib/survey4/main/urls.py @@ -0,0 +1,21 @@ +"""main URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url, include +from django.contrib import admin + +urlpatterns = [ + url(r'^', include('apps.survey4_app.urls')) +] diff --git a/rib/survey4/main/wsgi.py b/rib/survey4/main/wsgi.py new file mode 100644 index 0000000..4d1e3f4 --- /dev/null +++ b/rib/survey4/main/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for main project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + +application = get_wsgi_application() diff --git a/rib/survey4/manage.py b/rib/survey4/manage.py new file mode 100755 index 0000000..ad5d3e7 --- /dev/null +++ b/rib/survey4/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) + raise + execute_from_command_line(sys.argv) diff --git a/rib/time_display3/apps/__init__.py b/rib/time_display3/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/time_display3/apps/time_display3_app/__init__.py b/rib/time_display3/apps/time_display3_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/time_display3/apps/time_display3_app/admin.py b/rib/time_display3/apps/time_display3_app/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/rib/time_display3/apps/time_display3_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/rib/time_display3/apps/time_display3_app/apps.py b/rib/time_display3/apps/time_display3_app/apps.py new file mode 100644 index 0000000..f6bb527 --- /dev/null +++ b/rib/time_display3/apps/time_display3_app/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class TimeDisplay3AppConfig(AppConfig): + name = 'time_display3_app' diff --git a/rib/time_display3/apps/time_display3_app/migrations/__init__.py b/rib/time_display3/apps/time_display3_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/time_display3/apps/time_display3_app/models.py b/rib/time_display3/apps/time_display3_app/models.py new file mode 100644 index 0000000..bd4b2ab --- /dev/null +++ b/rib/time_display3/apps/time_display3_app/models.py @@ -0,0 +1,5 @@ +from __future__ import unicode_literals + +from django.db import models + +# Create your models here. diff --git a/rib/time_display3/apps/time_display3_app/templates/time_display3_app/index.html b/rib/time_display3/apps/time_display3_app/templates/time_display3_app/index.html new file mode 100644 index 0000000..4dd4c3f --- /dev/null +++ b/rib/time_display3/apps/time_display3_app/templates/time_display3_app/index.html @@ -0,0 +1,11 @@ + + + + Index Page + + +

Time Display III

+

The current time and date:

+

{{ time }}

+ + \ No newline at end of file diff --git a/rib/time_display3/apps/time_display3_app/tests.py b/rib/time_display3/apps/time_display3_app/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/rib/time_display3/apps/time_display3_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/rib/time_display3/apps/time_display3_app/urls.py b/rib/time_display3/apps/time_display3_app/urls.py new file mode 100644 index 0000000..27baa08 --- /dev/null +++ b/rib/time_display3/apps/time_display3_app/urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import url +from . import views + +urlpatterns = [ + url(r'^$', views.index), + +] \ No newline at end of file diff --git a/rib/time_display3/apps/time_display3_app/views.py b/rib/time_display3/apps/time_display3_app/views.py new file mode 100644 index 0000000..899b486 --- /dev/null +++ b/rib/time_display3/apps/time_display3_app/views.py @@ -0,0 +1,13 @@ +from django.shortcuts import render +import datetime + +def index(request): + print "Inside the index method" + context = { + 'time' : datetime.datetime.now() + } + return render(request, 'time_display3_app/index.html',context) + + + + diff --git a/rib/time_display3/db.sqlite3 b/rib/time_display3/db.sqlite3 new file mode 100644 index 0000000..daddac0 Binary files /dev/null and b/rib/time_display3/db.sqlite3 differ diff --git a/rib/time_display3/main/__init__.py b/rib/time_display3/main/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rib/time_display3/main/settings.py b/rib/time_display3/main/settings.py new file mode 100644 index 0000000..65d0762 --- /dev/null +++ b/rib/time_display3/main/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for main project. + +Generated by 'django-admin startproject' using Django 1.10.6. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.10/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'atg0o316554k7-odxz!j51s3%7^j!qd3rwnf+pkk2h3ak^2y%)' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'apps.time_display3_app', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'main.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'main.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/1.10/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.10/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/rib/time_display3/main/urls.py b/rib/time_display3/main/urls.py new file mode 100644 index 0000000..6864606 --- /dev/null +++ b/rib/time_display3/main/urls.py @@ -0,0 +1,21 @@ +"""main URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url, include +from django.contrib import admin + +urlpatterns = [ + url(r'^', include('apps.time_display3_app.urls')), +] diff --git a/rib/time_display3/main/wsgi.py b/rib/time_display3/main/wsgi.py new file mode 100644 index 0000000..4d1e3f4 --- /dev/null +++ b/rib/time_display3/main/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for main project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + +application = get_wsgi_application() diff --git a/rib/time_display3/manage.py b/rib/time_display3/manage.py new file mode 100755 index 0000000..ad5d3e7 --- /dev/null +++ b/rib/time_display3/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) + raise + execute_from_command_line(sys.argv)