mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	Merge pull request #24 from f/patch-2
Add more code examples to tutorial
This commit is contained in:
		
						commit
						c258003b8e
					
				
					 1 changed files with 34 additions and 5 deletions
				
			
		|  | @ -1,13 +1,13 @@ | ||||||
| # Kemal Tutorial | # Kemal Tutorial | ||||||
| 
 | 
 | ||||||
| ## Install Crystal | ## 1. Install Crystal | ||||||
| 
 | 
 | ||||||
| ``` | ``` | ||||||
| brew update | brew update | ||||||
| brew install crystal-lang | brew install crystal-lang | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## Installing Kemal | ## 2. Installing Kemal | ||||||
| 
 | 
 | ||||||
| You should create your application first: | You should create your application first: | ||||||
| 
 | 
 | ||||||
|  | @ -31,7 +31,15 @@ You should run `shards` to get dependencies: | ||||||
| shards install | shards install | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## Include Kemal into your project | It will output something like that: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | $ shards install | ||||||
|  | Updating https://github.com/sdogruyol/kemal.git | ||||||
|  | Installing kemal (master) | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ## 3. Include Kemal into your project | ||||||
| 
 | 
 | ||||||
| Open `awesome_web_project/src/awesome_web_project.cr` and require `kemal` to use Kemal. | Open `awesome_web_project/src/awesome_web_project.cr` and require `kemal` to use Kemal. | ||||||
| 
 | 
 | ||||||
|  | @ -39,7 +47,7 @@ Open `awesome_web_project/src/awesome_web_project.cr` and require `kemal` to use | ||||||
| require 'kemal' | require 'kemal' | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## Hack your project | ## 4. Hack your project | ||||||
| 
 | 
 | ||||||
| Do some awesome stuff with awesome Kemal. | Do some awesome stuff with awesome Kemal. | ||||||
| 
 | 
 | ||||||
|  | @ -49,11 +57,32 @@ get "/" do | ||||||
| end | end | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## Run your awesome web project. | All the code should look like this: | ||||||
|  | 
 | ||||||
|  | ```ruby | ||||||
|  | require "./crystal_test/*" | ||||||
|  | require "kemal" | ||||||
|  | 
 | ||||||
|  | module AwesomeWebProject | ||||||
|  |   get "/" do | ||||||
|  |     "Hello World!" | ||||||
|  |   end | ||||||
|  | end | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ## 5. Run your awesome web project. | ||||||
| 
 | 
 | ||||||
| ``` | ``` | ||||||
| crystal build --release src/awesome_web_project.cr | crystal build --release src/awesome_web_project.cr | ||||||
| ./awesome_web_project | ./awesome_web_project | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
|  | You should see some logs like these: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | [development] Kemal is ready to lead at http://0.0.0.0:3000 | ||||||
|  | 2015-12-01 13:47:48 +0200 | 200 | GET / - (666µs) | ||||||
|  | 2015-12-05 13:47:48 +0200 | 404 | GET /favicon.ico - (14µs) | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
| Now you can be happy with your new, very fast, readable web project. | Now you can be happy with your new, very fast, readable web project. | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue