Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Screen Shots/NavList_Thumbnails.tiff
Binary file not shown.
Binary file added Screen Shots/TabNav_Thumbnails.tiff
Binary file not shown.
13 changes: 12 additions & 1 deletion chap8.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# This is where the answers to Chapter 8 questions for the BSS Dev RampUp go
# Name:
# Name: Anthony Leonardi

def rotate_word(str, x):
newString = ''
for c in str:
temp=ord(c)
temp += x
temp = chr(temp)
newString += temp
return newString

print rotate_word('cheer', 7)
48 changes: 47 additions & 1 deletion chap9.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,48 @@
# This is where the answers to Chapter 9 questions for the BSS Dev RampUp go
# Name:
# Name: Anthony Leonardi

def read_file():
fin =open('words.txt')
for line in fin:
#word =fin.readline()
if len(line.strip()) >19:
print line

def has_no_e(str):
if 'e' in str:
return False
else:
return True
def avoids(word, forbidden):
for c in word:
if c in forbidden:
return False
return True

def read_file_avoids(forbidden):
fin = open('words.txt')
count = 0
for line in fin:
if avoids(line.strip(), forbidden):
count += 1
return count

def prompt_user():
forbidden = raw_input("enter a string of forbidden letters: ")
print read_file_avoids(forbidden)

def uses_only(word, allowed):
for c in word:
if c not in allowed:
return False
return True

print uses_only('alfalfa', 'alf')
print uses_only('anthony', 'the')
#prompt_user()

"""read_file()
print has_no_e('this')
print has_no_e('there')
print avoids('hello', 'abcde')
print avoids('hello', 'abcd')"""
Binary file added my_app/.DS_Store
Binary file not shown.
35 changes: 35 additions & 0 deletions my_app/fourth_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import flask
import settings

# Views
from main import Main
from login import Login
from remote import Remote
from music import Music

app = flask.Flask(__name__)
app.secret_key = settings.secret_key

# Routes
app.add_url_rule('/',
view_func=Main.as_view('main'),
methods=["GET"])
app.add_url_rule('/<page>/',
view_func=Main.as_view('main'),
methods=["GET"])
app.add_url_rule('/login/',
view_func=Login.as_view('login'),
methods=["GET", "POST"])
app.add_url_rule('/remote/',
view_func=Remote.as_view('remote'),
methods=['GET', 'POST'])
app.add_url_rule('/music/',
view_func=Music.as_view('music'),
methods=['GET'])

@app.errorhandler(404)
def page_not_found(error):
return flask.render_template('404.html'), 404

app.debug = True
app.run()
24 changes: 24 additions & 0 deletions my_app/login.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import flask, flask.views

users = {'anthony':'bacon'}

class Login(flask.views.MethodView):
def get(self):
return flask.render_template('login.html')

def post(self):
if 'logout' in flask.request.form:
flask.session.pop('username', None)
return flask.redirect(flask.url_for('login'))
required = ['username', 'passwd']
for r in required:
if r not in flask.request.form:
flask.flash("Error: {0} is required.".format(r))
return flask.redirect(flask.url_for('login'))
username = flask.request.form['username']
passwd = flask.request.form['passwd']
if username in users and users[username] == passwd:
flask.session['username'] = username
else:
flask.flash("Username doesn't exist or incorrect password")
return flask.redirect(flask.url_for('login'))
Binary file added my_app/login.pyc
Binary file not shown.
9 changes: 9 additions & 0 deletions my_app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import flask, flask.views
import os

class Main(flask.views.MethodView):
def get(self, page="index"):
page += ".html"
if os.path.isfile('templates/' + page):
return flask.render_template(page)
flask.abort(404)
Binary file added my_app/main.pyc
Binary file not shown.
10 changes: 10 additions & 0 deletions my_app/music.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import flask, flask.views
import os
import utils

class Music(flask.views.MethodView):
@utils.login_required
def get(self):
songs = os.listdir('static/music')
return flask.render_template("music.html", songs=songs)

Binary file added my_app/music.pyc
Binary file not shown.
14 changes: 14 additions & 0 deletions my_app/remote.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import flask, flask.views
import os
import utils

class Remote(flask.views.MethodView):
@utils.login_required
def get(self):
return flask.render_template('remote.html')

@utils.login_required
def post(self):
result = eval(flask.request.form['expression'])
flask.flash(result)
return flask.redirect(flask.url_for('remote'))
Binary file added my_app/remote.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions my_app/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
secret_key = "bacon"
Binary file added my_app/settings.pyc
Binary file not shown.
Binary file added my_app/static/.DS_Store
Binary file not shown.
Loading