Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hw7 #82

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open

Hw7 #82

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
034ca40
modified server.py
Jan 15, 2014
6e16d25
updated server.py
Jan 15, 2014
408817b
test code for hw2
ctb Jan 17, 2014
b26ff8a
added comments.
ctb Jan 17, 2014
239ea08
added send-post-request
ctb Jan 17, 2014
e48fed6
Merge branch 'hw2' of https://github.com/ctb/cse491-serverz into hw2
Jan 22, 2014
9a45b50
passing the first test
Jan 22, 2014
b803c24
added additional page responses
Jan 22, 2014
2f723e3
fixed tests for additional page responses
Jan 23, 2014
affd9eb
Added POST response and testing
Jan 23, 2014
42a08f3
please fix
Jan 29, 2014
b64562e
splitting stuff into seperate functions
Jan 29, 2014
d612bcd
adding the form
Jan 29, 2014
f97ab58
finishing hw3
Jan 30, 2014
945317f
Updating ChangeLog
Jan 30, 2014
65452dd
Update ChangeLog
Jan 30, 2014
f3ce526
Merge pull request #2 from fenderic/hw3
Feb 6, 2014
c413434
task 1 and 2
Feb 6, 2014
db0aea4
cleaning up code
Feb 6, 2014
f50e055
adding template folder for jinja2
Feb 6, 2014
b936d1d
adding templates hopefully
Feb 6, 2014
1767c2d
got jinja stuff working properly
Feb 6, 2014
34c9930
Everything but tests are working
Feb 6, 2014
0a2b110
Update ChangeLog
Feb 6, 2014
e77f2fc
added demo of app.py, ref-server
ctb Feb 7, 2014
02de89a
Merge branch 'hw5-wsgi' of https://github.com/ctb/cse491-serverz into…
Feb 13, 2014
7b5e481
got everything except submits working
Feb 13, 2014
6bbe3c5
Update ChangeLog
Feb 13, 2014
56f047b
POST is dumb
Feb 13, 2014
538003e
Merge branch 'hw5' of http://github.com/fenderic/cse491-serverz into hw5
Feb 13, 2014
95c1d92
fixed nosetest errors from hw4
Feb 13, 2014
e274fbf
added run-qx
ctb Feb 18, 2014
44cb867
eunbong's server
ctb Feb 18, 2014
70bea8e
updated eunbong's server.py for running quixote demo app
ctb Feb 18, 2014
abda0ae
finished part 1
Feb 21, 2014
1754157
quixote stuff
Feb 21, 2014
9aebeea
finished hw6. something wrong with image, but i'll fix tomorrow
Feb 22, 2014
67bab3f
initial commit of Quixote structure
ctb Feb 22, 2014
8dfa7e2
added setup/teardown
ctb Feb 22, 2014
271c2d9
a nice, small image upload app
ctb Feb 22, 2014
d471eda
starting hw7
Feb 27, 2014
f0e37b4
cookies working
Feb 27, 2014
886ee0c
merging in imageapp stuff
Feb 27, 2014
40149b7
doing the imageapp stuff
Feb 27, 2014
b730c46
jq and js
ctb Feb 27, 2014
b9f9163
added 2nd upload example
ctb Feb 27, 2014
b40e4dd
Merge branch 'day16' of https://www.github.com/ctb/cse491-serverz int…
Feb 27, 2014
3d45917
adding in the stuff we did in class. did my javascript and jquery stuff
Feb 27, 2014
5b264b8
fixing stuff i accidentally removed and added in class that broke my
Mar 11, 2014
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
6 changes: 6 additions & 0 deletions .coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
�}q(U collectorqUcoverage v3.7.1qUlinesq}q(UK/user/austine5/cse491.env/lib/python2.7/site-packages/nose/plugins/cover.pyq]q(K�K�K�K�eU0/user/austine5/491files/cse491-serverz/server.pyq]q (KKKK K K K"K#K%K'K(K+K2K4K6K8K=K?KAKCKEKGKIKKKMKOKSKWKYKkKlKoKqKtKuKxKzK}K~K�K�K�K�K�K�K�K�K�K�K�K�eUB/user/austine5/cse491.env/lib/python2.7/site-packages/nose/case.pyq
]q (KK!K"K$K%K&K'K(K)K*K-K;K<K@KEKFKJK�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�MM
M MMMeUG/user/austine5/cse491.env/lib/python2.7/site-packages/nose/pyversion.pyq ]q(K8KwK�K�eUB/user/austine5/cse491.env/lib/python2.7/site-packages/nose/core.pyq]q(K"K$K%K)K*K+K,K2K3K7K8K;K<K=K>K?K�K�K�K�K�K�K�K�K�K�K�eUD/user/austine5/cse491.env/lib/python2.7/site-packages/nose/loader.pyq]q(KOKQKRKSKTKUKVKYKZK[K\K]K^K_KaKcK�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�M<M=M>M?MCMDMEMGMHMJMKMLMMMNMOMTMUMVMWM_MbMlMnMqMrMuMvM�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�MMMMMMM!M"M*M/M1M8MBMCMEMHeUC/user/austine5/cse491.env/lib/python2.7/site-packages/nose/proxy.pyq]q(KK+K-K.K/K9K:K;K<K>K@KNKPKQKRKSKfKgKhKnKoKpKtKuKvK�K�K�K�K�K�K�K�K�eUM/user/austine5/cse491.env/lib/python2.7/site-packages/nose/plugins/capture.pyq]q(K9K:KDKpKqKrKuKveUC/user/austine5/cse491.env/lib/python2.7/site-packages/nose/suite.pyq]q(K4KCKGKHKJKKKNKOKPK]K^K_K`KaKbKcKfKgKhKiKjKpKqK�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�M MMMMMMMMMMMM M"M#M$M(M)M,M-M.M/M3M4M7M8M:MBMCMDMEMFMGMHMIMJMPMQMRMSMTMUMXMYMZM[M\M]M^McMdMeMgMhMkMlMnMoMsMtMuMwMxMyM�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�MMMMM M!M"M)M2M3M6eU5/user/austine5/491files/cse491-serverz/test_server.pyq]q(KKKKK K
K KKKKKKKKKKKK3K4K:K<K?K@KTKUKXKZK]K^KbKcKeKgKjKkKoKpKrKtKwKxK|K}KK�K�K�K�K�K�K�K�K�K�K�K�K�eUM/user/austine5/cse491.env/lib/python2.7/site-packages/nose/plugins/manager.pyq]q(KXKYK]K^K_K`KcKiKjKkKoKrKvKxKyK{K|K�K�K�K�K�K�K�K�K�K�K�K�K�K�eUF/user/austine5/cse491.env/lib/python2.7/site-packages/nose/importer.pyq]q(KK K(K)K*K,K-K/K5K6K;K>K?KAKBKCKDKFKGKHKKKLKMKNKOKPKQK^K`KaKbKcKeKgKhK�K�K�K�K�K�K�K�K�K�K�K�K�K�K�eUP/user/austine5/cse491.env/lib/python2.7/site-packages/nose/plugins/logcapture.pyq]q(KVK�K�K�K�K�K�K�K�K�K�eUP/user/austine5/cse491.env/lib/python2.7/site-packages/nose/plugins/errorclass.pyq ]q!(K�K�K�K�K�K�eUD/user/austine5/cse491.env/lib/python2.7/site-packages/nose/result.pyq"]q#(K&K'K(K)K+K,KgKhKiKjKmKneUB/user/austine5/cse491.env/lib/python2.7/site-packages/nose/util.pyq$]q%(K�K�K�K�K�K�K�K�K�K�K�K�MMMM M
MMMMMMMMPMQMRMSMUMVM�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�MMM
M MMMeUF/user/austine5/cse491.env/lib/python2.7/site-packages/nose/selector.pyq&]q'(K#K%K(K)K*K+K,K-K5K6K9KDKEKHKIKJKLKMKPKQKtKuKvKwK{K|K}K~KK�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�euu.
Expand Down
32 changes: 32 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
2014-01-07 Titus Brown <[email protected]>

* Initialized repository, created server.py and README.


2014-01-15 Eric Austin

* Completed Homework 1. Updated server.py to include the HTTP 1.0 response
and print out my netID and git username.


2014-01-22 Eric Austin

* Completed Homework 2. Added additional GET page responses and POST
response. And testing for them all.


2014-01-29 Eric Austin

* Completed Homework 3. Added POST and GET forms and tests.


204-02-06 Eric Austin

* Completed Homework 4. Cannot for the life of me figure out what I am
doing wrong with the tests. It's late and I am tired. I'll figure
it out eventually.


204-02-12 Eric Austin

* Working on Homework 5. Have everything working now except for the
GET and POST submit forms.


175 changes: 175 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# from http://docs.python.org/2/library/wsgiref.html

#import jinja2

from wsgiref.util import setup_testing_defaults

import jinja2
import cgi
# A relatively simple WSGI application. It's going to print out the
# environment dictionary after being updated by setup_testing_defaults
def simple_app(environ, start_response):
setup_testing_defaults(environ)

loader = jinja2.FileSystemLoader('./templates')
env = jinja2.Environment(loader=loader)


status = '200 OK'
headers = [('Content-type', 'text/html')]

start_response(status, headers)

ret = ["%s: %s\n" % (key, value)
for key, value in environ.iteritems()]
ret.insert(0, "This is your environ. Hello, world!\n\n")


method = environ['REQUEST_METHOD']
path = environ['PATH_INFO']

print path

if method == "POST":

if path == '/':

return handle_index('', env)


elif path == '/submit':

#return handle_submit_post('', env)
#return handle_submit_post(form, env)
return handle_submit_post(environ, env)


else:

return handle_404('', env)


elif method == "GET":

if path == '/':

return handle_index('', env)


elif path == '/content':

return handle_content('', env)


elif path == '/file':

headers = [('Content-type', 'text/plain')]
return handle_file('', env)


elif path == '/image':

headers = [('Content-type', 'image/jpeg')]
return handle_image('', env)


elif path == '/submit':

return handle_submit_get(environ, env)


else:

return handle_404('', env)


else:

return handle_404('', env)


#printing out the garbage at the top
return ret



def make_app():

return simple_app



def handle_index(params, env):

return str(env.get_template('index.html').render())


def handle_content(params, env):

return str(env.get_template('content.html').render())


def handle_file(params, env):

# return str(env.get_template('file.html').render())
fp = open('./files/quote.txt', 'rb')
data = fp.read()
fp.close()
return data

def handle_image(params, env):

# return str(env.get_template('image.html').render())
fp = open('./img/life-aquatic-with-steve-zissou-3.jpg', 'rb')
data = fp.read()
fp.close()
return data


def handle_404(params, env):

return str(env.get_template('404.html').render())


def handle_submit_get(params, env):

namestring = params['QUERY_STRING']
namestring = namestring.split('&')

first_name = namestring[0].split('=')[1]
last_name = namestring[1].split('=')[1]
name = dict(first_name = first_name, last_name = last_name)

return str(env.get_template('submit.html').render(name))


def handle_submit_post(environ, env):


headers = {}
for i in environ.keys():
headers[i.lower()] = environ[i]

print "before form!!!!!"
print "before headers"
print headers
print "after headers"
print "environ['wsgi.input']"
print environ['wsgi.input']
print "environ"
print environ

# breaking on something here.......

form = cgi.FieldStorage(headers = headers, fp = environ['wsgi.input'], environ = environ)

print "after form!!!!"

first_name = form['firstname'].value
last_name = form['lastname'].value
name = dict(first_name = first_name, last_name = last_name)

return str(env.get_template('submit.html').render(name))



1 change: 1 addition & 0 deletions files/quote.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
That pregnant slut is playing us like a cheap fiddle!
Loading