Array copy clone

//Protocal that copyable class should conform
protocol Copying {
    init(original: Self)
}

//Concrete class extension
extension Copying {
    func copy() -> Self {
        return Self.init(original: self)
    }
}

//Array extension for elements conforms the Copying protocol
extension Array where Element: Copying {
    func clone() -> Array {
        var copiedArray = Array<Element>()
        for element in self {
            copiedArray.append(element.copy())
        }
        return copiedArray
    }
}

//Simple Swift class that uses the Copying protocol
final class MyClass: Copying {
    let id: Int
    let name: String
   
    init(id: Int, name: String) {
        self.id = id
        self.name = name
    }
   
    required init(original: MyClass) {
        id = original.id
        name = original.name
    }
}

//Array cloning
let objects = [MyClass]()
//fill objects array with elements
let clonedObjects = objects.clone()

Tags: 

Blurred footprint

extension uiimage

public func modifiedImage(_ draw: (CGContext, CGRect) -> ()) -> UIImage {
       
        // using scale correctly preserves retina images
        UIGraphicsBeginImageContextWithOptions(size, false, scale)
        let context: CGContext! = UIGraphicsGetCurrentContext()
        assert(context != nil)
       
        // correctly rotate image
        context.translateBy(x: 0, y: size.height)
        context.scaleBy(x: 1.0, y: -1.0)
       
        let rect = CGRect(x: 0.0, y: 0.0, width: size.width, height: size.height)
       
        draw(context, rect)
       
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return image!
    }
public func tintPictogram(with fillColor: UIColor) -> UIImage {
       
        return modifiedImage { context, rect in
            // draw tint color
            context.setBlendMode(.normal)
            fillColor.setFill()
            context.fill(rect)
           
            // mask by alpha values of original image
            context.setBlendMode(.destinationIn)
            context.setAlpha(0.15)
            context.draw(cgImage!, in: rect)
        }
    }

general:
func blurImage(_ image:UIImage) -> UIImage? {
    let context = CIContext(options: nil)
    let inputImage = CIImage(image: image)
    let originalOrientation = image.imageOrientation
    let originalScale = image.scale
   
    let filter = CIFilter(name: "CIGaussianBlur")
    filter?.setValue(inputImage, forKey: kCIInputImageKey)
    filter?.setValue(3.0, forKey: kCIInputRadiusKey)
    let outputImage = filter?.outputImage
   
    var cgImage:CGImage?
   
    if let asd = outputImage
    {
        cgImage = context.createCGImage(asd, from: (inputImage?.extent)!)
    }
   
    if let cgImageA = cgImage
    {
        return UIImage(cgImage: cgImageA, scale: originalScale, orientation: originalOrientation)
    }
   
    return nil
}

use:
if let image = UIImage(named:name)
            {
                 let tintimg = image.tintPictogram(with: .black)
                if let shadowedimage = blurImage(tintimg){
                //...    shadowImages.append(shadowedimage)
                }
               
            }

Tags: 

notes from new es6

probeer in:
http://jsbin.com/

imports

You got two different types of exports: default (unnamed) and named exports:

default => export default ...;

named => export const someData = ...;

You can import default exports like this:

import someNameOfYourChoice from './path/to/file.js';

Named exports have to be imported by their name:

import { someData } from './path/to/file.js'

snips

const myName = 'hjh';
///console.log(myName);

function printName(name){
  console.log(name);
}
const printName2 = (name,age) =>{
  console.log('2: '+name+' age: '+age);
}
//printName("hhhh");
//printName2("hhhh");

const multiply = (number) =>{
  return number * 2;
}
const multiply2 = number => number * 2;

//printName(multiply(4));
//printName(multiply2(4));

class Person{
 
  constructor(name){
    this.name = name;
  }
 
  call() {
    console.log( 'hi from '+ this.name);
  }
}
const p = new Person('hjc');
p.call();

const numbers = [1,2,3];
//spread
const newNumbers = [...numbers,4];
console.log('newNumbers: '+newNumbers);
const newPerson = {
  ...p,
  age: 26
}
console.log(newPerson)

const filter = (...args) => {
  return args.filter(el => el === 1);
}

console.log('filter : '+filter(1,2,3));

[num1,num2] = numbers;
console.log(num1,num2);

// Arrrays & Class's are copied by reference!

const person3 = {
  name: 'Max'
}

const person4 = person3;
const person5 = {
  ...person3
}
person3.name = 'Manu';

console.log(person4);
console.log(person5);

// array .map function
const doubleNumbers = numbers.map((num)=> {return num*2});
console.log('double numbers '+doubleNumbers);

meer array functions
map() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
find() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
findIndex() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
filter() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
reduce() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
concat() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
slice() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
splice() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...

react components playground:
https://codepen.io

Tags: 

React Native notes

ESlint

npm install --save-dev eslint-config-rallycoding 

create .eslintrc:
{
  "extends":"rallycoding"
}

create-react-native-app AwesomeProject
cd AwesomeProject
npm start

down grading nom 5 =>4
npm install -g npm@4

Tags: 

shake animations

func shakeByRotateView(view:UIView){
    let shake:CABasicAnimation = CABasicAnimation(keyPath: "transform.rotation")
    shake.duration = 0.12
    shake.repeatCount = Float.infinity
    shake.autoreverses = true
   
    shake.fromValue = NSNumber(value: 0.05*Double.pi)
    shake.toValue = NSNumber(value: -0.05*Double.pi)
    view.layer.add(shake, forKey: "lineRotation")
}

func shakeView(view:UIView){
    let shake:CABasicAnimation = CABasicAnimation(keyPath: "position")
    shake.duration = 0.1
    shake.repeatCount = 2
    shake.autoreverses = true
   
    var from_point:CGPoint = CGPoint(x:view.center.x - 5,y: view.center.y)
    var from_value:NSValue = NSValue(cgPoint: from_point)
   
    var to_point:CGPoint = CGPoint(x:view.center.x + 5,y: view.center.y)
    var to_value:NSValue = NSValue(cgPoint: to_point)
   
    shake.fromValue = from_value
    shake.toValue = to_value
    view.layer.add(shake, forKey: "position")
}

Tags: 

Python rest_framework Docker setup

Dockerfile

FROM python:3

ENV PYTHONUNBUFFERED = 1
RUN mkdir /code
WORKDIR /code
COPY . /code/
RUN pip install -r requirements.txt

docker-compose.yml

FROM python:3

ENV PYTHONUNBUFFERED = 1
RUN mkdir /code
WORKDIR /code
COPY . /code/
RUN pip install -r requirements.txt

docker-compose run web python src/profiles_project/manage.py migrate

docker-compose up

Codable Decodable

class Excercise: Encodable,Decodable {
    var date:Date
    var remarks:[String]
   
    init(date:Date,remarks:[String]) {
        self.date = date
        self.remarks = remarks
    }
 
}

let x = Excercise(date:Date(),remarks:["avc","def"])
let encoder = JSONEncoder()
let jsonData = try encoder.encode(x)
String(data: jsonData, encoding: .utf8)!//"{"date":531262938.28764498,"remarks":["avc","def"]}"
let decoder = JSONDecoder()
let decoded = try decoder.decode(Excercise.self, from: jsonData)
decoded.date//"Nov 1, 2017 at 10:01 PM"
decoded.remarks//["avc", "def"]
type(of: decoded)//Excercise.Type

Tags: 

UILabel outlined / stroked text

class StrokedLabel: UILabel {
   
    var strockedText: String = "" {
        willSet(newValue) {
            let strokeTextAttributes = [
                NSAttributedStringKey(rawValue: NSAttributedStringKey.strokeColor.rawValue) : UIColor.black,
                NSAttributedStringKey(rawValue: NSAttributedStringKey.foregroundColor.rawValue) : UIColor.white,
                NSAttributedStringKey(rawValue: NSAttributedStringKey.strokeWidth.rawValue) : -4.0,
                NSAttributedStringKey(rawValue: NSAttributedStringKey.font.rawValue) : UIFont.boldSystemFont(ofSize: 30)
                ] as [NSAttributedStringKey : Any]?
           
            let customizedText = NSAttributedString(string: newValue
                , attributes: strokeTextAttributes)
           
           
           
            attributedText = customizedText
        }
    }
}

Tags: 

raspi config ssh problem

ssh pi@192.168.1.27
Connection reset by 192.168.1.27 port 22
solution:

sudo rm /etc/ssh/ssh_host_* && sudo dpkg-reconfigure openssh-server

Path Finding

import GameplayKit

let graph = GKGraph()


let nodeA = GKGraphNode()
let nodeB = GKGraphNode()
let nodeC = GKGraphNode()
let nodeD = GKGraphNode()
let nodeE = GKGraphNode()


graph.addNodes([nodeA,nodeB,nodeC,nodeD,nodeE])
nodeA.addConnectionsToNodes([nodeB,nodeD], bidirectional: true)
nodeB.addConnectionsToNodes( [nodeD], bidirectional: true)
nodeC.addConnectionsToNodes( [nodeE], bidirectional: false)
nodeD.addConnectionsToNodes( [nodeC], bidirectional: false)
let path:[GKGraphNode] = graph.findPathFromNode(nodeA, toNode: nodeE)

Tags: 

Server side Swift

Kitura

mkdir serverside
cd serverside/
mkdir server
cd server
docker run -itv $(pwd):/projects --name projects -w /projects -p 8089:8089 -p 8090:8090 -p 5984:5984 twostraws/server-side-swift /bin/bash
docker start projects
docker attach projects
root@c661e0faa890:/projects# mkdir project1
root@c661e0faa890:/projects# cd project1/
root@c661e0faa890:/projects/project1# swift package init --type executable
root@c661e0faa890:/projects/project1# swift build
root@c661e0faa890:/projects/project1# .build/debug/project1
Hello, world!

change package to:
let package = Package(
name: "project1",
dependencies: [
.Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 1),
.Package(url: "https://github.com/IBM-Swift/HeliumLogger.git", majorVersion: 1),
.Package(url: "https://github.com/IBM-Swift/Kitura-StencilTemplateEngine.git", majorVersion: 1)
]
)

swift build
swift package generate-xcodeproj

docker ps - shows a list of running containers
docker ps -a shows list all projects

docker start #NAME PROJ#
docker attach #NAME#
ctrl-p ctrl-q to get back to local terminal without stopping
docker start -i #NAME#

Vapor

Use & adjust Post template.
change in fluent.json
"driver":"memory" into "driver":"sqlite"

create
sqlite.json
insert
{
"path":"pokemonDB.sqlite"
}

in config+Setup
change setupPreparations into desired Pokemon class

private func setupPreparations() throws {
        preparations.append(Post.self)
        preparations.append(Pokemon.self)
    }

in router
get("version"){
            request in
            let result = try Pokemon.database?.driver.raw("select sqlite_version();")
            return try JSON(node: result)
        }

MySql

start mysql server
docker run -p 3306:3306 --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest

Tags: 

bitbucket push origin problem

With Bitbucket problem on the raspi :
git push -u origin master
Counting objects: 87, done.
error: pack-objects died of signal 9
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
../html# fatal: write error: Bad file descriptor

git config pack.windowMemory 10m
git config pack.packSizeLimit 20m

combine adding CGRects in array

Adding two CGRect:

let area0 = CGRectZero //{x 0 y 0 w 0 h 0}
let area1 = CGRect(x:0,y:0,width: 2.0, height: 2.0)//{x 0 y 0 w 2 h 2}
let area2 = CGRect(x:2.0,y:2.0,width: 2.0, height: 2.0)
let area3 = CGRect(x:4.0,y:4.0,width: 2.0, height: 2.0)
let union = CGRectUnion(area1, area2)//{x 0 y 0 w 4 h 4}

in an array
var areatotal:[CGRect] = []
areatotal.append(area1)
areatotal.append(area2)
areatotal.append(area3)
areatotal.append(area0)
areatotal.reduce(CGRectZero, combine: CGRectUnion)//{x 0 y 0 w 6 h 6}

Tags: 

Nginx

apt-get update
apt-get install nginx
service nginx start

Download the init script for the relevant platform and save it to /etc/rc.d/init.d/nginx
chmod +x /etc/rc.d/init.d/nginx

directives and context

renumber id column

SET @i=0;
UPDATE table_name SET column_name=(@i:=@i+1);

set @rank=0;select @rank:=@rank+1 as rank , screenname, score from gameScore order by score desc;

select groep , screenname from user where userGroup.groep < 98 order by groep;

Tags: 

remove mongo

# See if mongo is in the launch/startup list
launchctl list | grep mongo

# Remove mongodb from the launch/startup
launchctl remove homebrew.mxcl.mongodb

# Kill the mongod process just in case it's running
pkill -f mongod

# Now you can safely remove mongodb using Homebrew
brew uninstall mongodb

Tags: 

Docker

Sails

run sails from local dir in docker conatiner
docker container run -it -p 1337:1337 -v $(pwd):/server artificial/docker-sails /bin/bash

Swift

run docker app
then

docker pull swift
docker pull postgres:alpine

docker container run -d -p 3306:3306 --name mysql -e MYSQL_RANDOM_ROOT_PASSWORD=yes  mysql
docker container run --name mysql -p 3306:3306 -e MYSQL_RANDOM_ROOT_PASSWORD=yes -d mysql
docker container logs mysql
docker exec -it mysql bash -l

docker container run -d --name mysql -e MYSQL_ROOT_PASSWORD=root -p 3306 -v /Users/lappie2010/Documents/docker/mysql/:/var/lib/mysql mysql


docker container logs mysql

docker container run -d --name webserver -p 8080:80 httpd

docker container run -d --name proxy -p 80:80 nginx


docker run --cap-add sys_ptrace -it --privileged=true swift bash

Docker Mysql + Wordpress

docker container run -d \
    --name wordpress \
--link mysql:mysql\
    -p 8080:80 \
    -e WORDPRESS_DB_PASSWORD=root \
    wordpress

    docker container run -d \
        --name mysql \
        -e MYSQL_ROOT_PASSWORD=root \
        -e MYSQL_DATABASE=wordpress \
        mysql

Tags: 

Swift Perfect

mkdir hjh
cd hjh
swift package init --type executable
swift package generate-xcodeproj
open ./hjh.xcodeproj/

edit package.swift

import PackageDescription
let package = Package(
  name: "hjh",
  dependencies: [
    .Package(url: "https://github.com/PerfectlySoft/Perfect-
HTTPServer.git", majorVersion: 2),
    .Package(url: "https://github.com/SwiftORM/SQLite-StORM.git",
majorVersion: 1, minor: 0),
    .Package(url: "https://github.com/PerfectlySoft/Perfect-
Mustache.git", majorVersion: 2),
] )

terminal:

swift package update
swift package generate-xcodeproj

main.swift:

import PerfectLib
import PerfectHTTP
import PerfectHTTPServer

terminal:

mkdir public
touch public/file.txt
swift package generate-xcodeproj

terminal:

mkdir public
touch public/file.txt
swift package generate-xcodeproj

let server = HTTPServer()
server.serverPort = 8080
server.documentRoot = "public"

do {
  try server.start()
} catch PerfectError.networkError(let err, let msg) {
  print("Network error thrown: \(err) \(msg)")
}

// func for fitst json response
func jsonresponsefunc(request: HTTPRequest, response: HTTPResponse) {
  do {
    try response.setBody(json: ["message": "JSON!"])
      .setHeader(.contentType, value: "application/json")
      .completed()
  } catch {
    response.setBody(string: "Error handling request: \(error)")
      .completed(status: .internalServerError)
  }
}
// routes
var routes = Routes()
routes.add(method: .get, uri: "/", handler: jsonresponsefunc)
server.addRoutes(routes)

Tags: 

Read file

file io swift 2.2

        let fileLocation = NSBundle.mainBundle().pathForResource("2311393", ofType: "xml")!
        let text : String
        do
        {
            text = try String(contentsOfFile: fileLocation)
        }
        catch
        {
            text = ""
        }

Tags: 

App installed

func isAppInstalled(name:String)->Bool {
    return UIApplication.sharedApplication().canOpenURL(NSURL(string:"\(name):")!)
}

Tags: 

Meteor setup project with accounts

Router:

meteor add iron:router

Bootstrap:

meteor add twbs:bootstrap

Accounts:

meteor add accounts-ui accounts-password
meteor add joshowens:accounts-entry
meteor npm install --save bcrypt
meteor add check

adjust client with code from
https://github.com/Differential/accounts-entry/

meteor

Install
cd $HOME

git clone --depth 1 https://github.com/4commerce-technologies-AG/meteor.git

#now it installs if it is the first time!
$HOME/meteor/meteor --version

==========================
======= slow version =======
==========================

cd $HOME

git clone --depth 1 https://github.com/4commerce-technologies-AG/meteor.git

cd meteor

Build bundled node:

scripts/build-node-for-dev-bundle.sh

Get mongodb installation from OS (e.g. Debian based):

sudo apt-get install mongodb

Optional (long runner) build bundled mongo:

scripts/build-node-for-dev-bundle.sh
Beneath the compiler and development tools and standard libaries, you have to also install the zlib1g-dev (or whatever it's named on your OS) library sources. Otherwise the mongo build will fail with an error like "-lz is missing"

Build meteor dev_bundle:

scripts/generate-dev-bundle.sh

Check installed version:

$HOME/meteor/meteor --version
==========================
========= helpfull snips =====
==========================

cd $HOME

# get the command line to checkout the meteor example
$HOME/meteor/meteor create --example simple-todos-react

# this is what you will receive as command hint, so put it in
git clone https://github.com/meteor/simple-todos-react

# jump into the project folder
cd simple-todos-react

# get necessary npm stuff
$HOME/meteor/meteor npm install

# bring that project up to latest module updates
$HOME/meteor/meteor update --packages-only

# add one package to avoid counting of modules usage and DDP error message on start
$HOME/meteor/meteor add package-stats-opt-out

# run that app
$HOME/meteor/meteor

Raspberry gpio

Read value

import RPi.GPIO as GPIO

# read value
GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.IN)
poweron = GPIO.input(21)
GPIO.cleanup(21)

print "turnonheater"
    GPIO.setup(21,GPIO.OUT, initial=GPIO.HIGH)
    GPIO.output(21, GPIO.HIGH)
    GPIO.cleanup(21)

print "turnoffheater"
    GPIO.setup(21,GPIO.OUT, initial=GPIO.LOW)
    GPIO.output(21, GPIO.LOW)
    GPIO.cleanup(21)

Crash Log Helper

.h

@interface CrashLogHelper : NSObject

+(void) writeNoCrashFile;
+(void) removeNoCrashFile;

.m
+(void) writeNoCrashFile
{
    NSError *error;
    NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"crashloggername.txt"];
    NSLog(@"file path for write nocrash file%@", filePath);
    NSFileManager *filemgr;
   
    filemgr = [NSFileManager defaultManager];
   
    if ([filemgr fileExistsAtPath: filePath ] == YES)
    {
        NSLog (@"File exists, so it did crash");
        [App.persistenceHelper setString:@"-1" forPersistentKey:PERSISTENCEHELPER_ratingsequence];
    }
    else
    {
        NSLog (@"File not found");
        // write new file
        NSString *stringToWrite = @"no crash";
        [stringToWrite writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:&error];
    }
}
+(void) removeNoCrashFile
{
    NSFileManager *filemgr;
    NSError *error;
    filemgr = [NSFileManager defaultManager];
    NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"crashlogger.txt"];
  
    if ([filemgr fileExistsAtPath: filePath ] == YES){
        NSLog (@"File exists so remove");
        BOOL success = [filemgr removeItemAtPath:filePath error:&error];
        if (success) {
            NSLog(@"file removed");
        }
        else
        {
            NSLog(@"Could not delete file -:%@ ",[error localizedDescription]);
        }
    }
    else{
        NSLog (@"File not found"); // something fishy
    }
   
}

Tags: 

Screenwidth screen height

+ (CGFloat) getScreenWidth
{
    CGFloat swidth = [UIScreen mainScreen].bounds.size.width;
    CGFloat sheight = [UIScreen mainScreen].bounds.size.height;
    return MIN(swidth, sheight);
}

+ (CGFloat) getScreenHeight
{
    CGFloat swidth = [UIScreen mainScreen].bounds.size.width;
    CGFloat sheight = [UIScreen mainScreen].bounds.size.height;
    return MAX(swidth, sheight);
}

Tags: 

Read Write file IO

+(void) writeTextFile
{
    NSError *error;
    NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"text.txt"];
    NSFileManager *filemgr;
   
    filemgr = [NSFileManager defaultManager];
   
    if ([filemgr fileExistsAtPath: filePath ] == YES)
    {
        NSLog (@"File exists");
    }
    else
    {
        NSLog (@"File not found");
        // write new file
        NSString *stringToWrite = @"text text text";
        [stringToWrite writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:&error];
    }
}
+(void) removeTextFile
{
    NSFileManager *filemgr;
    NSError *error;
    filemgr = [NSFileManager defaultManager];
    NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"text.txt"];
  
    if ([filemgr fileExistsAtPath: filePath ] == YES){
        NSLog (@"File exists so remove");
        BOOL success = [filemgr removeItemAtPath:filePath error:&error];
        if (success) {
            NSLog(@"file removed");
        }
        else
        {
            NSLog(@"Could not delete file -:%@ ",[error localizedDescription]);
        }
    }
    else{
        NSLog (@"File not found"); // something fishy
    }
   
}

Tags: 

port mysql

SHOW GLOBAL VARIABLES LIKE 'PORT';

Tags: 

Drupal small core update drush

sudo apt-get update

put in maintenance mode:
drush vset --exact maintenance_mode 1 drush cache-clear all
update:
drush pm-update drupal
put out of maintenance mode:
drush vset --exact maintenance_mode 0 drush cache-clear all

Swift raspberry

sudo apt-get update
sudo apt-get install -y clang
wget https://s3-us-west-2.amazonaws.com/swiftpi.swiftlite.v1/swift-lite-3.0-r...
sudo tar -xzpf swift-lite-3.0-raspberrypi-universal.tar.gz -C/

examples
wget https://s3-us-west-2.amazonaws.com/swiftpi.swiftlite.v1/helloworld3.tar.gz
tar -xzpf helloworld3.tar.gz

cleanup
rm swift-lite-3.0-raspberrypi-universal.tar.gz helloworld3.tar.gz

to build
cd swiftProjects
swift-lite-build helloworld.swift

test/run
./helloworld.swapp

swift server Kitura

first

mkdir tuinhok
cd tuinhok
swift package init --type executable

adjust Package.swift
import PackageDescription


let package = Package(
  name: "proj1",
  dependencies: [
    .Package(url: "https://github.com/IBM-Swift/Kitura.git",
             majorVersion: 1),
    .Package(url: "https://github.com/IBM-Swift/HeliumLogger.git", majorVersion: 1),
    .Package(url: "https://github.com/IBM-Swift/Kitura-StencilTemplateEngine.git", majorVersion: 1)
    ]
)

swift package generate-xcodeproj
mkdir public - for js css img etc
mkdir Views - for stencil files

in main swift
import Kitura
import LoggerAPI
import HeliumLogger
import KituraStencil

HeliumLogger.use(.info)
let router = Router()
router.setDefault(templateEngine: StencilTemplateEngine())
router.all("/static", middleware: StaticFileServer())

router.get("/") {
  request, response, next in
  defer { next() }
  try response.render("home", context: [:])
}

Kitura.addHTTPServer(onPort: 8090, with: router)

Kitura.run()

Tags: 

Pages

Subscribe to hjsnips RSS