I use Rails, and I'll briefly explain how Rails displays pages.
First, Rails adopts a design pattern called MVC.
This stands for Model, View, Controller, which are responsible for database, display, and processing, respectively.
This time, I'll explain View. View is the part that generates HTML.
So, let me briefly explain how pages are actually displayed.
Explanation
// config/routes.rb
get 'userinfo/index'
First, what this means is that it will respond when you access userinfo/index, or more specifically, http://localhost:3000/userinfo/index. What is displayed at this URL is created through various script filters.
// app/controllers/userinfo_controller.rb
def index
@var = 'hello.'
end
For example, before a page is displayed at that URL, something called an action is applied. A collection of these actions is apparently called a controller.
So what do you write in this action? It's where you write Ruby scripts. It's where you write programs. When working locally on a regular basis, I think you write a fair amount of code when creating a project or tool. You write such Ruby code in this action.
Then, you put the data finally output from the code, the data you wanted, into some instance variable.
The database operations... here we call it a model, but operations on this model are also done here. Or rather, it's just that they should be done. It's apparently because that way is easier to understand and read.
// app/views/userinfo/index.html.erb
# Userinfo#index
<p>Find me in app/views/userinfo/index.html.erb</p>
<%= @var %>
Then, finally, the URL passes through this file. This file is an ERB file, a special HTML file.
This file is displayed almost as-is on the web page, that is, on the userinfo/index that appeared at the very beginning.
Here, we're outputting the @var that was casually defined in the action earlier as text into the HTML.
So, do you do all this work manually? This is where Rails comes in handy,
rails g controller USERINFO index
With just this one command, it creates folders, files, and code for you.
In the above example, the only difference is @var = 'hello.', which I added.