B1 中級 3 タグ追加 保存
動画の字幕をクリックしてすぐ単語の意味を調べられます!
単語帳読み込み中…
字幕の修正報告
What's going on?
Everybody welcome apart.
Nine of Amer go language tutorial.
Siri's in this video.
What we're gonna be covering is MME.
Or on the Web server and serving information back to the browser.
Just some basic stuff that we should probably cover before we get into the nitty gritty Sze.
So with that, I'm start with a blank screen here.
I guess it conserve is just kind of a reminder of the Web development basics.
But anyways, package May we're also gonna import a couple things.
One is the just the format and then also net slash h t t p.
Then we're gonna have funk, uh, index underscore Handler and in the parameters here it's W.
And then that's a http dot response writer.
And then we had our for the request, which is a point through to http dot request uh, and now we can begin the function and let's just do format Don't f printout using the writer, uh and then hey there for now and then finally weakened due are Funk Main Empty Farms and http dot handle funk handle.
Let's try our best not to type out swear words and, uh, index handler and then finally age to be.
Don't listen and serve.
You can also, if you had like https, for example, you could listen to serve tea.
L s, um, not really gonna cover that now, but that just letting you know that exists.
Uh, 40,000 and then obviously you would serve on a different port.
But anyway, back to what we were doing past Mill, go and say that and let's make sure that runs a CZ.
We would hope so.
Go, run, Go touch go dot Go.
Uh, what did hope this comma that's gonna keep getting me some python you got?
You know, you'd have to put in that calm.
I'm probably gonna python Forget comments.
Yeah, uh, subject their unexpected funk.
Expecting it's not jumping out at me with this issue.
Would be index handler past W response writer, huh?
Okay.
From the print, that should be fine.
Main handle the funk.
The index handler http don't listen and served 48,000.
Know what do he is a single quote.
Yes, We use single quotes.
That's what's getting us.
If I would have read the air and full, I would have seen that immediately.
All right, Let's try it again.
Area that's gonna work.
Allow, and then I'll head to it.
All right, we got hey there.
So obviously we generally like that's just plain text, like, review.
The source of justice is a there.
Um, usually in hte e mail, we have things called tags.
So what can we do to pass tax?
Well, we actually, we can pass tags.
Um, just by writing them in if we wanted.
So let's just do a header one, for example.
And then I'm just gonna restart the server real quick.
Maybe hit, allow.
Here we go.
Right.
And now it's Hey there.
And then if we refreshed source, we see us, the tags actually came through and all that s so then we could add, like, a few more things like, let's just say maybe two more lines make this may be a paragraph tag, and then we'll make this one a paragraph tie, and then we can say goes fast and simple so and then we can refresh our server.
I'm just breaking and restarting it.
So control c and then just up a roto Rhea, we run it basically.
And then as you can see, we got that on separate lines and all that.
It works as you would have expected.
Uh, the other thing I want to show really briefly is Let's just make another line.
And we could do something like this.
Like we could say, um, you percent s even add percent s comma, and then we can put in what we wanna have there so we could say can And and then we can also say, What did I do here?
Okay, so it has been strong and then passed variables.
So you can even add variables like this using the percent esos good.
Break this, Rerun it, allow it.
We shouldn't have to hit, allow every time fresh, pull it over.
And there you go.
Hey, there goes fast and simple.
You can even add variables.
The next thing I want to show, though, is if we were to view the source here, everything's on just like one line, which I mean, it's Brian at the end of the world, but, um, in general way would like this to be organized like you would expect, Especially when things start getting like if you were gonna actually coda Web site doing this.
Thank you.
Probably wouldn't.
You probably moved to using templates, which will show at a later time.
Um, but if you were doing it this way, it would be very hard for you to debug your own website.
Especially if you've got issues like you forgot to close the tag somewhere.
It's really hard to find it, and it's gonna be equally it's hard to find it if, uh if it looks like that.
So, um so the other thing we could do is you can actually do, like, a multi line print.
So this is true with all the prints, you don't have to use f print.
You could.
This could just be like your typical print line, for example.
Um, but what I'm gonna go ahead and do is let's say we wanted this exact same code, So format dot f f um, Let's just let us do these 1st 3 I think, um, and then you can use the little Tilly and then you can use that to make a multi line print.
So, for example, we could throw it away, don't need clothes.
We could throw in that this and we'll just go in this one just for just to show it.
Okay, we can save that, actually.
Gonna get rid of these two.
So we'll save that and then already started server.
Perhaps we have a mistake.
Not enough arguments.
We forget that W the writer, Trigon.
There it goes, Refresh and basically kind of the same thing.
Everything's on a separate line.
And if we were to go view the source, you'd see well, it's almost good enough, but not quite so the issue is the tabbing is at least yet, like in the start.
It's not going to be tabbed weird, but then down here, in theory, these tabs or part of the multi line.
So it's thinking you want those tabs so you could get rid of them just by removing the taps butting.
And that's pride, not which you would want either.
And so again, I'll just kind of let you know that it does exist, that there are gonna be html templates.
And like I said, we can look into those, um, later on for solving this sort of a problem.
But again, we could be a source refresh, and there we go.
We fix that problem, but it is kind of you could in theory, do quite a bit of programming and make even some slightly complicated Web sites just by passing variables just like we've done here and using all the information that we've learned up to this point, we could actually make a but decent recite, to be honest.
But in general, I think you'll find that using templates will be a little easier.
Been doing it this way.
But anyways, um, I think that's all I want really show right now, as far as like just adding one later.
On top of the stuff that we've seen so far in the next tutorial, we're actually going to start building our project.
So the project that I wanted to do, I just basically want to do anything but a blawg.
So the project I decided that we we could do is to basically make like a news aggregator using like the site maps from a new source.
So So that's what we're gonna d'oh uh, and I think that will kind of allow us to bring in a bunch of concepts that were trying to learn and at the same time kind of actually used them on a riel example rather than something that's like a toy example, because, ah, a lot of things really do change when you try to go from, like, a basic example to actually applying it.
So, um, so, anyways, we're actually gonna start building that code that's going to start doing that for us.
We're gonna do that in the next tutorial.
So that's what you guys have to look forward to if you've got questions, comments, concerns, whatever feel free we'll even below.
Otherwise, I'll see you in the next tutorial.
コツ:単語をクリックしてすぐ意味を調べられます!

読み込み中…

More web dev basics - Go Lang Practical Programming Tutorial p.9

林宜悉 2020 年 4 月 1 日 に公開
お勧め動画
  1. 1. クリック一つで単語を検索

    右側のスプリクトの単語をクリックするだけで即座に意味が検索できます。

  2. 2. リピート機能

    クリックするだけで同じフレーズを何回もリピート可能!

  3. 3. ショートカット

    キーボードショートカットを使うことによって勉強の効率を上げることが出来ます。

  4. 4. 字幕の表示/非表示

    日・英のボタンをクリックすることで自由に字幕のオンオフを切り替えられます。

  5. 5. 動画をブログ等でシェア

    コードを貼り付けてVoiceTubeの動画再生プレーヤーをブログ等でシェアすることが出来ます!

  6. 6. 全画面再生

    左側の矢印をクリックすることで全画面で再生できるようになります。

  1. クイズ付き動画

    リスニングクイズに挑戦!

  1. クリックしてメモを表示

  1. UrbanDictionary 俚語字典整合查詢。一般字典查詢不到你滿意的解譯,不妨使用「俚語字典」,或許會讓你有滿意的答案喔