Зміст курсу
Вступ до Хмарних Обчислень
Вступ до Хмарних Обчислень
Зберігання фрагментів коду на AWS S3
In the previous chapter, we wrote HTML code that allows us to feed the turtle, and in this code, we used an image that we uploaded to AWS S3 in a public bucket. But you may have noticed that reading the code from there was quite inconvenient due to the large number of styles.
I'm leading up to the fact that we can also upload certain code snippets to AWS S3, just like images. For example, in our case, it would be convenient to upload CSS styles for our HTML pages or applications to AWS in order to save space in the code.
Let's take a look at the style file I want to upload to the storage:
index.css
To add a file with styles to AWS S3, we first need to create the file and upload it to our public bucket:
To apply these CSS styles in your HTML code, you just need to use a straightforward syntax:
У випадку посилання на наші стилі, цей рядок виглядатиме так:
Давайте подивимося, наскільки наш код буде скорочено після наших змін і як він виглядатиме зараз:
index.html
If you click and follow this link, you'll see the contents of this file, specifically the styles I wrote earlier. This way, both we and the visitors to our website can view the styles stored on AWS and may want to borrow them from us.
script.js
Now, we need to use the following syntax to add the script to the code via the link:
Після додавання скрипту з AWS S3, наш код для черепахи виглядатиме так:
Примітка
До речі, ви можете ще раз переглянути скрипт безпосередньо за посиланням.
index.html
Дякуємо за ваш відгук!