Sunday, October 8, 2017

Creating a Simple Web App

Create the app 

The first thing I did was go into the web tab and create a new web app.  This creates a directory in which I can create and edit the files making up the website. *Please click the photos to enlarge them :)





This is the mysite directory.  








Creating "hello"

In order to create the hello directory that will be the hello page of this site I typed this command:
into a Bash console which created these files:


Connect the view

In order to link the view to the site there are a few things that need to be done.  First I updated the hello/views.py file to look like this:
I then had to create a new urls.py file for the hello directory, this is done by just creating a new file and updating it like so:

creating the file






hello/urls.py










Next I had to link this to the mysite/urls.py file:

Lets see if it worked!

Running the command python manage.py runserver 8002 starts a server with the port number 8002.  

Now if I go to my domain name and specifically the hello page at jpernick.pythonanywhere.com/hello we can see that it worked!  The page is displayed with the message.  

Thank you for reading! Next week I will be creating a polling application using a couple cool features in Django.  Please comment your thoughts and anything you would like to see in future blogs!

No comments:

Post a Comment