All Projects → PerfectlySoft → Perfecttemplate

PerfectlySoft / Perfecttemplate

Licence: other
Empty Perfect Starter Project.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Perfecttemplate

Hummingbird
Lightweight, flexible HTTP server framework written in Swift
Stars: ✭ 114 (-48.42%)
Mutual labels:  server-side-swift, http-server
Swiftengine
Apple Swift based HTTP server. The answer for a Swift based, turn key, crash resilient, high scale, and production grade web server.
Stars: ✭ 660 (+198.64%)
Mutual labels:  server-side-swift, http-server
Qxorm
QxOrm library - C++ Qt ORM (Object Relational Mapping) and ODM (Object Document Mapper) library - Official repository
Stars: ✭ 176 (-20.36%)
Mutual labels:  http-server
Restrserve
R web API framework for building high-performance microservices and app backends
Stars: ✭ 207 (-6.33%)
Mutual labels:  http-server
Moleculer Web
🌍 Official API Gateway service for Moleculer framework
Stars: ✭ 198 (-10.41%)
Mutual labels:  http-server
Zio Http
A scala library to write Http apps.
Stars: ✭ 162 (-26.7%)
Mutual labels:  http-server
Miniserve
🌟 For when you really just want to serve some files over HTTP right now!
Stars: ✭ 2,894 (+1209.5%)
Mutual labels:  http-server
Http4s
A minimal, idiomatic Scala interface for HTTP
Stars: ✭ 2,173 (+883.26%)
Mutual labels:  http-server
Aiohttp Wsgi
WSGI adapter for aiohttp.
Stars: ✭ 218 (-1.36%)
Mutual labels:  http-server
Elli
Simple, robust and performant Erlang web server
Stars: ✭ 194 (-12.22%)
Mutual labels:  http-server
Swoole Bundle
Symfony Swoole Bundle
Stars: ✭ 201 (-9.05%)
Mutual labels:  http-server
Catacumba
Asynchronous web toolkit for clojure built on top of Ratpack / Netty
Stars: ✭ 192 (-13.12%)
Mutual labels:  http-server
Http Kit
http-kit is a minimalist, event-driven, high-performance Clojure HTTP server/client library with WebSocket and asynchronous support
Stars: ✭ 2,234 (+910.86%)
Mutual labels:  http-server
Fiery
A flexible and lightweight web server
Stars: ✭ 203 (-8.14%)
Mutual labels:  http-server
Mineserver
🚗 http server implementation for java native nio api
Stars: ✭ 179 (-19%)
Mutual labels:  http-server
Tinywebserver
🔥 Linux下C++轻量级Web服务器
Stars: ✭ 4,720 (+2035.75%)
Mutual labels:  http-server
Rayo.js
Micro framework for Node.js
Stars: ✭ 170 (-23.08%)
Mutual labels:  http-server
Onlineswiftplayground
Online Swift Playground
Stars: ✭ 192 (-13.12%)
Mutual labels:  server-side-swift
Donkey
Modern Clojure HTTP server and client built for ease of use and performance
Stars: ✭ 199 (-9.95%)
Mutual labels:  http-server
Http
🚀 Non-blocking, event-driven HTTP built on Swift NIO.
Stars: ✭ 220 (-0.45%)
Mutual labels:  server-side-swift

PerfectTemplate 简体中文

Get Involed with Perfect!

Star Perfect On Github Stack Overflow Follow Perfect on Twitter Join the Perfect Slack

Swift 5.0 Platforms macOS | Linux License Apache PerfectlySoft Twitter Slack Status

Perfect Empty Starter Project

This repository holds a blank Perfect project which can be cloned to serve as a starter for new work. It builds with Swift Package Manager and produces a stand-alone HTTP executable.

Compatibility with Swift

The master branch of this project currently compiles with Xcode 10 and the Swift 4.1 or higher toolchain on Ubuntu.

Building & Running

The following will clone and build an empty starter project and launch the server on port 8181.

git clone https://github.com/PerfectlySoft/PerfectTemplate.git
cd PerfectTemplate
swift run

You should see the following output:

[INFO] Starting HTTP server localhost on 0.0.0.0:8181

This means the server is running and waiting for connections. Access http://localhost:8181/ to see the greeting. Hit control-c to terminate the server.

Starter Content

The template file contains a simple "hello, world!" request handler and shows how to serve static files, and compress outgoing content.

import PerfectHTTP
import PerfectHTTPServer

// An example request handler.
// This 'handler' function can be referenced directly in the configuration below.
func handler(request: HTTPRequest, response: HTTPResponse) {
	// Respond with a simple message.
	response.setHeader(.contentType, value: "text/html")
	response.appendBody(string: "<html><title>Hello, world!</title><body>Hello, world!</body></html>")
	// Ensure that response.completed() is called when your processing is done.
	response.completed()
}

// Configure one server which:
//	* Serves the hello world message at <host>:<port>/
//	* Serves static files out of the "./webroot"
//		directory (which must be located in the current working directory).
//	* Performs content compression on outgoing data when appropriate.
var routes = Routes()
routes.add(method: .get, uri: "/", handler: handler)
routes.add(method: .get, uri: "/**",
		   handler: StaticFileHandler(documentRoot: "./webroot", allowResponseFilters: true).handleRequest)
try HTTPServer.launch(name: "localhost",
					  port: 8181,
					  routes: routes,
					  responseFilters: [
						(PerfectHTTPServer.HTTPFilter.contentCompression(data: [:]), HTTPFilterPriority.high)])

Further Information

For more information on the Perfect project, please visit perfect.org.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].