Tuesday, November 26, 2013

Changes 11/25/13

Math Drill:

  • Wrote a login.tpl page with user and password fields
  • Researched hashing algorithms and how to safely store passwords
  • Began creating a database to hold username and password and eventually other stuff

Friday, November 22, 2013

Changes 11/22/13

Math Drill:

  • Fixed 500 Internal Server error: I typed student.trim() rather than student.strip(), and it didn't print out the stack trace for some reason, making it very hard to troubleshoot
  • This was fixed in two ways:
    • Code was added to make it able to run with both python3 run.py and google_appengine/dev_appserver.py projects/math_drill/:
    • dev = False
      # If -l flag is used, run in python3 mode
      if (len(sys.argv) > 1 and (sys.argv[1] == '-l' or sys.argv[1] == '-local')):
          dev = True
          print('RUNNING IN LOCAL MODE (Non Google App Engine)')

      if dev:
          app = bottle
      else:
          app = Bottle()

      curdir = ''
      if dev:
          curdir = os.path.dirname(os.path.abspath(__file__)) + '/'


      ...
      # Other Code

      ...

      if dev:
          bottle.run()
      else:
          bottle.run(app=app, server="gae", debug=True)

    • The second, MUCH easier way of fixing the problem is simply to add debug=True to the bottle.run() statement (making it bottle.run(app=app, server="gae", debug=True)). This causes the stack trace to print on the 500 Internal Server Error page itself (although the stack trace still doesn't print in the console)
  • The add/remove students functionality of the /admin/students/ page finally seems to be working as intended

Thursday, November 21, 2013

Changes 11/21/13 Part 2

Math Drill:

  • Made a .vimrc file to set tab to four spaces, which makes python programming much easier
  • Added comments to postStudents() method explaining what certain code does
  • Saved the <textarea> input to a variable so that it can be parsed and added to students[]
  • Learned that you can write mergedList = list1 + list2, which is good to know for future code 
  • Keep running into weird problems where the server will give a 500 page but not output any python errors.  This is frustrating and it is very hard to tell what is going wrong.

Changes 11/21/13 Part 1

Math Drill:

  • Fixed the list of deletions not checking against the right string
  • Used '<br>'.join(debuglist) to easily print the list of students in html form, this is a pretty useful python function
  • Checking the delete box now removes that student from the students[] list, but not the text file (yet)
  • Got a lot of "internal server error" without a stack trace or anything, so that took a while to fix.  I still don't know what was causing that
  • Added a textarea for entering additional students

Wednesday, November 20, 2013

Changes 11/20/13

Post-Note:

Math-Drill:

  • Added page /admin/students, which dynamically generates a list of all the students names with checkboxes next to them, using embedded code in the template file
  • % for student in students:
        {{student}}: <input type="checkbox" name="{{student}}_delete" value="Delete"><br>
    % end
  • Added method to POST /admin/students/submit
  • Submit button returns a page listing which students are being kept and deleted (although nothing actually changes yet)

Tuesday, November 19, 2013

Changes 11/19/13

Post Note:

  • Fixed the "_blank" attribute on the form, which was causing a new tab to open
  • Updated css to style the page
  • Added bottle.redirect('/') so that the pages refreshes when submit is pressed
  • Updated form to have two text boxes, one for the submitter name and one for the actual text
  • Added checks to make sure the data has been submitted properly without blank fields

Friday, November 15, 2013

Changes 11/15/13

Post-note (Bottle app):

  • Simple bottle app to look at how POST works for bottle and web forms in general
  • Text box allows for text entry, and when submit is clicked, the text from the text box is put in a variable, which is then set to a <h2> element
  • Code was largely copied from Math Drill and adapted
  • Learned about the app.post() method and how it interfaces with the webpage
  • Learned about the python global keyword and how it is used
  • Interestingly, the global  message variable seems to clear itself after awhile; I assume this is due to Google's hosting servers wanting to save resources
  • App was uploaded to Google App Engine (after learning the process with Math Drill it was really easy, too)
  • App is live at www.post-note.appspot.com
  • Styling and other stuff is eventually going to be added
  • The code will probably be cleaned up, since this is serves as a good example for how POST works in bottle

Thursday, November 14, 2013

Changes 11/14/13

Math-Drill:

  • Updated to Version 1-1:
  • Added new images that better show how the app will be used
  • Apparently in app.yaml you need threadsafe: set to something
  • Also I found this resource for building the app.yaml file
  • Interestingly, after updating the app, you have to manually set the new version as default by going to the versions tab

App Engine:

Wednesday, November 13, 2013

Changes 11/13/11

Web Design:

  • Added Math Drill link to homepage banner
  • Added styling for an <hr> element with class=solid_dark that allows for a border only on the top and bottom, but not sides of an element to be added (used in banner and navigation sections so far)
  • Couldn't figure out why the <hr> element has a 1px gap under the <nav> element (any ideas?)

Tuesday, November 12, 2013

Changes 11/12/11

Web Design:

  • Switched <link> tag loading stylesheet to style="@import(general.css);"
  • <link> tag documentation for html5 is very confusing, says if you want to use it in body you should use the itemprop attribute instead of rel, but I couldn't figure out what to set itemprop to. w3 <link> docs
  • Tried to figure out why jQuery code wasn't picking a random color on page load, but couldn't figure out the syntax

Friday, November 8, 2013

Changes 11/8/13

Web Design:

  • Made padding on the header links table look better
  • Changed what the header said
  • Added links to blog and another page to header
  • Added a custom <hr> element to create a border only on the bottom of the header
  • For some reason the page won't validate, and I couldn't figure out why. The error was:
    Line 56, Column 61: Element link is missing required attribute property. <link href="css/header.css" rel="stylesheet" type="text/css">

Thursday, November 7, 2013

Changes 11/7/13

Django:

  • Read some of the Django documentation

Web Design:

  • Set body margin to 0 on page
  • Started working on a header for the page
  • learned about <link> element for linking to css stylesheets, apparently it's better to use than @import url()

Wednesday, November 6, 2013

Changes 11/6/13

The post below will not be updated, please refer to this page instead

Converting a Bottle program to be Google App Engine compatible:

  1. Downloaded Google App Engine Python SDK and used google_appengine/dev_appserver.py math_drill/ rather than python3 run.py to build while testing
  2. Added from bottle import * in the import statements (I think that fixed something)
  3. Added app = Bottle() in order to:
    • Change all of the default @bottle.route() statements to @app.route() because that was causing errors
    • Changed bottle.run() statement to be bottle.run(app=app, server="gae")
  4. Created a file app.yaml:
    application: math-drill
    version: 1
    runtime: python27 #Python3 not supported, so 2.7 was used
    api_version: 1
    threadsafe: no #One tutorial said to do this, but since threads are not used it probably doesn't matter
    
    handlers:
    - url: /static
      static_dir: static
    
    - url: /.*
      script: run.app #Using run.py causes strange debug output to show up on the webpage
    
  5. With that all set up, it was uploaded to GAE using google_appengine/appcfg.py update math_drill/

Resources Used

Monday, November 4, 2013

Changes 11/4/13

Bottle:

  • Did a ton of troubleshooting and fixing and got GAE to accept the app
  • Added code app = Bottle(), and changed bottle.run() to app.run, etc
  • Almost uploaded it but didn't have time

Friday, November 1, 2013

Changes 10/1/13

Bottle:

  • Fixed refresh button, making it use location.reload(true) instead of history.go(0)
  • Uploaded math_drill to students.gctaa.net so it can be added to bottle zoo so proud

SO PROUD

  • Installed google app engine and set up yaml file
  • I think it isn't finding the template directory though because the page loads with no lines of html or anything