Coder Social home page Coder Social logo

ktor-backend-kt's Introduction

ktor-backend

Simple Kotlin backend using Ktor

About

It will return sample data with image on API GET request

Start

Go to https://start.ktor.io/ and create a project starter.

Use

Open project in IntelliJ and Run it.

Check the URL in the console logs and click on it or type the URL in the browser.

Call the API:

/randomfox

{
id: "2",
name: "Emma",
description: "Emma likes to eat apples",
imageUrl: "http://0.0.0.0:8080/fox/fox2.jpg"
}

/fox?foxId=3

{
"id": "3",
"name": "Florian",
"description": "Florian is always hungry",
"imageUrl": "http://0.0.0.0:8080/fox/fox3.jpg"
}

/fox?foxId=22

{
error: "Item does not exit"
}

/foxes

[
    {
    "id": "1",
    "name": "Florian",
    "description": "Florian is always hungry",
    "imageUrl": "http://0.0.0.0:8080/fox/fox3.jpg"
    },
...
]

Docker

Prepare JAR file

First lets build the project to generate the jar file:

  • Under Gradle Task, find the task "fatJar", and run it (double click)
  • Run it to make sure it is working properly
cd build/libs/
java -jar com.mrthiago.ktor-backend-0.0.1.jar

It should run just as if you had press Run in the IDE.

Dokerfile

Build

docker build -t rest-fox .

Run

docker run --name rest-fox-demo -p 8080:8080 rest-fox

Acknowledgment

Tutorials / Sources

Resources

Future reading / useful resources

ktor-backend-kt's People

Watchers

James Cloos avatar Thiago avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.