My page now uses the Wikipedia API in order to provide the user with more information about a chosen topic! An API (Application Programming Interface) allows for one computer to get information directly from another computer. For example, if I have a web application and I want to include data from Wikipedia in my application, I can use Wikipedia's API in order to pull the information that I want. In fact, that is exactly what I am doing now with this project. Whenever a note is created on my page, the user has the option to include some tags, which show up at the bottom of the note. If you click on the tag, you can find some snippets of information taken from Wikipedia that are related to that tag. This will help you determine what to search for if you want to learn more about that topic. In order to implement this feature in my page, I had to utilize two major resources: The Wikipedia API page, and the Python documentation for parsing JSON (links to those resources can be found below, under "Documents"). The Wikipedia API page was extremely useful because it helped me understand how to use Wikipedia's API. Some simple examples are provided that show what a typical API query looks like. I learned that I needed to have a base URL, then add some query parameters to the end of it in order to get the data that I wanted. The page also shows a video which introduced me to how to use the API. Particularly useful was the information telling me what format I could expect my data. The page informed me that I could request either XML or JSON, but encouraged JSON (as XML and other formats were less popular and support for those might lag in the future). I built the query in python and I was able to retrieve JSON data for a particular query, but I still needed to learn how to parse the JSON. That is when I went to the Python documentation for the JSON module. The documentation showed me all of the functions that were included in the module, and examples for how to use each one. In particular, I was looking for ways to take a JSON object and convert it into Python code so that I could parse it. Right near the top of the page I found my function: json.loads. However, just because I used this function on my JSON object didn't mean that I immediately understood what I was looking at; it all seemed a mess. So I went back to the documentation and it also had some functions for how to make it appear organized, which they called "pretty printing". Using json.dumps, I was able to effectively debug my code and find the information that I wanted. This page of Python documentation told me everything I could ever want to know about the python json module.
Validation is extremely important as it controls what information the user is allowed to send to the server. However, it must be done in a way that seems natural and makes for a pleasant user experience. If the user has submitted invalid data, it is a good idea to let them know exactly how their submission is invalid so that they can know how to fix it. This pages uses an error message that tells the user how the data they submitted is invalid. Validation also involves accounting for when the user tries to submit blank forms.
The purpose of servers is to respond to HTTP requests. HTTP is one of the major protocols of the web, and my computer uses HTTP to communicate with the server that hosts the website that I want to look at. The server responds to the requests of my computer. A server may have two types of responses: static and dynamic. Static content includes pre-written files that the server returns (e.g. images). Dynamic responses are created on the fly by a program that is running on the server. Programs hosted on web servers that serve dynamic content to requests are known as web applications. The request that my computer sends to the server is called a "GET Request". This is a request to "get" whatever page I'm looking for on that server. The server responds to my get request by delivering whatever it was that I requested. My computer sends a get request, the server sends a response. Another type of request is called a "POST Request". This sends a message to the server with instructions on what changes to make to whatever page I'm specifying. POST requests are used to update, change, or modify things on the server. For example, submitting this note will send a POST request to the server telling it to add a new note to the database. It will then redirect to the main page, which will then issue a GET request to show that page.
Please find my full, detailed notes in the links below under "Documents". Databases are crucial to any webapp. They allow for data gathered from the user to be stored so that it can be retrieved later (for example, if someone wants to log in to their account). Databases have to conform to the concept of ACID - that is, they must be Atomic (all transactions must occur, none), Consistent (should not return stale data; as soon as data is input, it should be available for retrieval), Isolation (all operations on a database should be independent of each other), and Durable (data put into the database should be there when you need it later; it shouldn't go missing).
Please see my full notes for this topic in the documents below. HTML templates allow us to greatly simplify the process of making webpages. Usually you want all your pages to have, if not the same basic layout, then at least similar themes. That is where templates come into play. You can create a base template that all other html pages that you write are based on. That way, if you need to make a change to the header or layout of your site, you only need to change the base template and not every page in the site. Templates make your code much more maintainable. Furthermore, templates allow you to run code inside them so that your web pages are more dynamic.
Please find my note below in the "Documents" section. Validation is an extremely important aspect of web development because you never know what your users will put in a form. At the very least, they could input data that is incorrect; but if you neglect validation, then a malicious user can completely disable and take over your site. Always ensure that you validate user input on the server side so that you only get information that you want from the user.
Find a link to my notes in the "Documents" section below.
You may find a link to my notes in the "Documents" section below.
A network is a group of entities that can communicate with each other though they are not directly connected. Networks can be measured two main ways: latency and bandwidth. Latency is the time it takes for a message to get from its source to its destination, and is measured in seconds or milliseconds. Bandwidth is the amount of information that can transmitted per unit time. This is usually measured in bits per second. A bit is the currency of networks - it is the smallest unit of information. In order to have a functioning network, we need to have rules for them to follow. These rules are protocols. An important protocol that we have been working with is HTTP protocol, which is the protocol of the World Wide Web. There are also other protocols, such as FTP.
Instance variables are variables that are associated with every instance of a created object. Whenever an instance of that object is created, the instance variables assume their values. Class variables, however, are variables that ALL instances of a certain object in a class should share. Inheritance is when a class inherits certain traits from a parent class. This is important because it allows us to reuse code and makes code easier to maintain. However, with inheritance, if a child class inherits from a parent class, there may be some traits or methods that you want to define specifically for that child class; when you do that, the method that would be inherited is 'overridden' by the one you wrote for the child class. This is called method overriding. Use of instance variable, class variables, inheritance, and method overriding are powerful tools in your OOP arsenal.