English subtitles

← Running the Forum - Intro to Relational Databases

Get Embed Code
4 Languages

Showing Revision 4 created 05/25/2016 by Udacity Robot.

  1. For the rest of this lesson, you
    are going to be working on Python code
  2. that should already be in the forum
    sub-directory of your vagrant directory.
  3. You can edit this code with your
    favorite text editor on your computer,
  4. and when you save it,
  5. those changes will be visible
    from inside the virtual machine.
  6. So, what is this code?
  7. It's a web forum,
    just not a very good one yet.
  8. You could run it like any Python
    program from the command line.
  9. And once it starts up, it'll tell you
    it's listening on port 8000 and then you
  10. can access it at http://localhost:8000
    in your web browser.
  11. And when you do,
    you'll see something like this.
  12. Hm, it's pretty empty.
  13. Let's put some posts in it.
  14. Now, if we go back to our terminal, and
  15. kill the web server with Ctrl C,
    and then restart it and
  16. go back to the web browser and
    reload all our posts are gone.
  17. What's going on there?
  18. Now, if we look over in the source code
    for this module that forum.py is using,
  19. we'll, see, it's not actually
    using a database at all.
  20. It's faking it with plain old variables
    which go away when the program exits.
  21. So for the next few exercises,
  22. you're going to be adapting this code to
    use a database to make posts persistent.
  23. First off,
  24. let's say hello to the database system
    that we're going to use, PostgreSQL.