Skip to content

Commit

Permalink
Project set-up and static serving
Browse files Browse the repository at this point in the history
  • Loading branch information
hhariri committed Mar 26, 2020
1 parent 10da4ff commit cef64e4
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 29 deletions.
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.gradle/
build/
/.gradle
/.idea
/out
/build
*.iml
out/
.DS_Store
.idea/
gradle/
*.ipr
*.iws
42 changes: 21 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
transformation or translation of resources Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
Object form, made available under the License, as indicated by resources
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
represent, as resources whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
Expand All @@ -57,31 +57,31 @@
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
designated in writing by the copyright owner as "Not resources Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
on behalf of whom resources Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
this License, each Contributor hereby grants to You resources perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
this License, each Contributor hereby grants to You resources perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
institute patent litigation against any entity (including resources
cross-claim or counterclaim in resources lawsuit) alleging that the Work
or resources Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
Expand All @@ -91,8 +91,8 @@
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(resources) You must give any other recipients of the Work or
Derivative Works resources copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
Expand All @@ -103,15 +103,15 @@
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
(d) If the Work includes resources "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
include resources readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
of the following places: within resources NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
within resources display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
Expand All @@ -123,7 +123,7 @@
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
for any such Derivative Works as resources whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

Expand Down Expand Up @@ -155,7 +155,7 @@
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
incidental, or consequential damages of any character arising as resources
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
Expand All @@ -164,7 +164,7 @@

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
and charge resources fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
Expand All @@ -181,7 +181,7 @@
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
comment syntax for the file format. We also recommend that resources
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Expand All @@ -190,7 +190,7 @@

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
You may obtain resources copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)


# Creating a static website with Ktor
# Creating resources static website with Ktor

This repository is the code corresponding to the hands-on lab [Creating a website with Ktor](https://play.kotlinlang.org/hands-on/Creating%20a%20website%20with%20ktor/01_Introduction).
This repository is the code corresponding to the hands-on lab [Creating resources website with Ktor](https://play.kotlinlang.org/hands-on/Creating%20a%20website%20with%20ktor/01_Introduction).
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ktor_version=1.3.2
kotlin.code.style=official
kotlin_version=1.3.70
logback_version=1.2.1
17 changes: 17 additions & 0 deletions src/main/kotlin/com/jetbrains/handson/website/Application.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.jetbrains.handson.website

import io.ktor.application.Application
import io.ktor.http.content.resources
import io.ktor.http.content.static
import io.ktor.routing.routing


fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)

fun Application.module() {
routing {
static("/static") {
resources("files")
}
}
}
9 changes: 9 additions & 0 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ktor {
deployment {
port = 8080
port = ${?PORT}
}
application {
modules = [ com.jetbrains.handson.website.ApplicationKt.module ]
}
}
17 changes: 17 additions & 0 deletions src/main/resources/files/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Static Page</title>
</head>
<body>
<h1>Static Page</h1>
<p>

</p>
<p>
This is a static page!
</p>
<img src="ktor.png" alt="Ktor Logo">
</body>
</html>
Binary file added src/main/resources/files/ktor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="trace">
<appender-ref ref="STDOUT"/>
</root>
<logger name="org.eclipse.jetty" level="INFO"/>
<logger name="io.netty" level="INFO"/>
</configuration>

0 comments on commit cef64e4

Please sign in to comment.