π Hello World
In this tutorial, weβre going to build an app that exposes a single endpoint and responds with a static response.
When weβre done, we should be able to make a GET request to the / endpoint:
curl --request GET \ --url http://localhost:8080And our server should respond with the following response:
HTTP/1.1 200 OKConnection: closeContent-Length: 21Content-Type: text/plain; charset=utf-8
Welcome to Dart Frog!Creating a new app
Section titled βCreating a new appβTo create a new Dart Frog app, open your terminal, cd into the directory where
youβd like to create the app, and run the following command:
dart_frog create hello_worldYou should see an output similar to:
β Creating hello_world (0.1s)β Installing dependencies (1.7s)
Created hello_world at ./hello_world.
Get started by typing:
cd ./hello_worlddart_frog devRunning the development server
Section titled βRunning the development serverβYou should now have a directory called hello_world β cd into it:
cd hello_worldThen, run the following command:
dart_frog devThis will start the development server on port 8080:
β Running on http://localhost:8080 (1.3s)The Dart VM service is listening on http://127.0.0.1:8181/YKEF_nbwOpM=/The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/YKEF_nbwOpM=/devtools/#/?uri=ws%3A%2F%2F127.0.0.1%3A8181%2FYKEF_nbwOpM%3D%2Fws[hotreload] Hot reload is enabled.Make sure itβs working by opening http://localhost:8080
in your browser or via cURL:
curl --request GET \ --url http://localhost:8080If everything succeeded, you should see Welcome to Dart Frog!.
π Congrats, youβve created a hello_world application using Dart Frog. View
the
full source code.