Monday, November 20, 2017

Styling the page

Styling the page

For my last post I will show a couple different ways to make the website look good, something I haven't covered much of.  To start I created a Django app 
which then creates the following file tree
Next I opened up a bash console and cd'ed into the directory containing manage.py and ran the following commands, running the command tree shows the file tree. 
This creates the the following files 
Then I updated the urls file to include the index.html 
Next I made some changes to index.html, which I created in the style directory.
There's a number of  ways to change the html but one way to to do it is to put everything into a style tag.  The tags for body, h1, h2, h3 etc. all style that specific div on the page.  For this I decided to change the color of the text, centers the text, and then changes the background color of the text which is a like the highlighted color.  You can check it out at jpernick.pythonanywhere.com/.

As always thank you for reading and please post any comments or questions. 

-Joe

Tuesday, November 14, 2017

Bottle App

Bottle App

This week I will be creating a Bottle app.  Bottle is great for a number of things including prototyping ideas, learning how web frameworks are built, and running personal or simple web apps. Bottle is contained within a single large source file called bottle.py that makes it easier to get the app up and running as well as read and see how Bottle framework interacts with the web application code. *Please click on the photos to enlarge them

Getting Started

The first thing I did was go to the web tab and create a new bottle app:
I will be using the same domain name that I have been previously using jpernick.pythonanywhere.com.  Next, I saved and ran a script to create a todo.db database file as well as a table in which I will store the items of the todo list.  This is what the script looks like:
I have also decided to store the code for this in a file called todo.py.  This is what the file tree looks like after running the script:
Next I updated code to include the route jpernick.pythonanywhere.com/todo,  this is the code:
Next week I will be implementing a template as well.  As always thank you for reading and please write me any comments or questions you may have.  
-Joe

Thursday, November 9, 2017

Password Protection

Password Protection

This week I will be continuing with the same comment app from last post and adding a password to protect it from spam.  The app is always up for comments to be posted at http://jpernick.pythonanywhere.com/. The username and password are both "hockey18".  *Please click on photos to enlarge them.

How its done

Right now the website can be accessed by anyone which can lead to annoying spam preventing it from being used to the fullest.  
before
after

Python anywhere gives a really easy way to protect your site.  Simply go to the web tab, scroll all the way down and there is a heading called password protection. There is a tab that needs to be switched from disabled to enabled, and then I put in a username and password. (both of which I made "hockey18"). 

Next it is important to scroll back up to the top of the page and click the green reload button, this applies the changes I just made. 
Now when I go to my url http://jpernick.pythonanywhere.com/ I am prompted to put in a username and password. The username is hockey18 and the password is also hockey18. 
Once the username and password are entered correctly the app is free to be used regularly.  The username and password only have to be entered once a session. 

Thank you for reading and please leave comments on anything you would like to see next!
-Joe