Join Troy Miles for an in-depth discussion in this video Serving HTML pages, part of Web Servers and APIs using C++.
- [Narrator] Route handlers look at the path passed to…the website and decide which code should handle it.…The only handler that we currently have is…for the root route, which matches either…an empty string or a lone forward slash.…Let's update it to return an html file instead of a string.…So, first we want to come up here,…and below our current using namespace,…we'll add one more.…And this is gonna be for crow.…And we'll come down here to the crow route…and we don't need any of this,…so we'll delete the old code…and here we're gonna say const request...…
req and then we'll say response,…res.…And then the first thing that we're gonna do here…is we're gonna say create an ifstream,…name it in,…and we're gonna pass to it a string,…which is gonna be public /index.html.…That's right here.…
And we're gonna pass to it an ifstream colon in…because we want to read this file in.…Then, we're gonna say if in, we're gonna make sure…that we actually got a file handler.…And if we did, we're gonna say create a string stream…and call it contents and then we'll insert…
- Working with Crow, the C++ micro web framework
- Deploying containers to Heroku
- Building websites and webpages
- Accessing data from a database
- Accessing data via RESTful APIs
- Creating API endpoints
- Running WebSockets on Heroku
Skill Level Intermediate
1. Installing Our Tools
2. Deploying to Heroku
Installing the Heroku CLI1m 17s
3. Building Websites
4. Data Access
5. RESTful APIs
6. WebSockets and Crow
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.