Description
Task 1
The platform chosen to host the web service and the database has been Amazon Web Services (AWS), in particular, Elastic Beanstalk. The name of the environment is Cs3204cloud-env, which runs a Python Flask web application. The URL for this web service is: http://cs3204cloudenv.eba-wfbammam.eu-west-1.elasticbeanstalk.com/
Figure 1: Elastic Beanstalk environment
After deploying the web application, we can see the most recent events in the logs section. The application deployment has been successful, and it is running correctly.
Figure 2: Recent events
If we browse the website (http://cs3204cloud-env.eba-wfbammam.eu-west-
1.elasticbeanstalk.com/) we can see the index page:
Figure 3: Website
The web application consists in a service that displays weather data obtained from sensors in the Cork airport. All the data is obtained in JSON format from the Central Statistics Office API (https://data.cso.ie/). We can get the URLs to obtain the data from the API as indicated:
We first browse the website and search what kind of data do we want, in this case, we are interested in climate data.
Figure 4: Central Statistics Office API
We select Temperature:
Figure 5: Central Statistics Office API
Figure 6: Central Statistics Office API
We obtain the following results:
Figure 7: Central Statistics Office API
We can also get the links to obtain this data with our web application using HTTP GET requests:
Figure 8: Central Statistics Office API
If we browse that link, we obtain the same data in JSON format. The field that we are interested in is “result.value”:
Figure 9: Central Statistics Office API
The web application obtains all the data that it needs from the JSON API making use of prepared URLs, processes it to display it in a table and stores it in a database:
Figure 10: application.py
The web design consists of a HTML5 file (index.html) with embedded CSS:
Figure 11: index.html
The dynamically obtained data is rendered by Flask using templates:
Figure 12: index.html
Task 2
By making use of RDS, we can create a relational database to store the data processed by the application. In this case, we are using MySQL:
Figure 13: RDS database
If we click on the instance, we can see information related to performance, connections, state of the database, region, etc:
Figure 14: RDS database
The database can be accessed in awseb-e-bkyayhc2mq-stack-awsebrdsdatabasexlcgvdroj3s0.ceajd2uuokj4.eu-west-1.rds.amazonaws.com in port 3306:
Figure 15: RDS database
To allow connections from outside the cloud to the database we must add a security rule:
Figure 16: RDS security rules
We add a rule to the firewall to allow MySQL connections from anywhere:
Figure 17: RDS security rules
Now, we can remotely connect to the database using our credentials and create the tables that we want:
Figure 18: Connection to database
We can use a SQL script to create the table faster:
Figure 19: table.sql
Figure 20: Create table with a SQL script
In the web application we connect to the database using our credentials and we update it with the data obtained from the JSON API:
Figure 21: Connection to database in Python
Figure 22: Update database
Conclusions
I found this lab quite interesting and useful. I think I have improved the knowledge I already had in web development, and in fact I have learned to use a new framework like Flask. It has also allowed me to put into practice my knowledge of databases, especially in the use of MySQL. I think that services like Elastic Beanstalk make it much easier to deploy web applications, both frontend and backend.
However, during the development of this lab I encountered some problems at the beginning, when I tried to deploy a simple example website with Flask. To begin with, it was necessary to indicate in a requirements file the necessary libraries to be installed by the platform in the environment. On the other hand, it was necessary to call the Flask object that represents the web application as “application” so that the web application could run on the platform without errors. Finally, the zip file that has to be uploaded to the platform must have a specific structure, and the files must be located outside of a main directory that groups them together.
I also found it a bit challenging to get data from the API because I had to understand the different data that each request returned and how to generate the right URLs to get it. On the other hand, the creation of the database and the table with the data produced by the web application seemed easy to me, partly because I already had experience with MySQL in Linux environments.
References
Link to application code in GitHub: https://github.com/SergiDelta/CS3204_Lab_2
Reviews
There are no reviews yet.