A very basic proof-of-concept Swift HTTP server that does not require Foundation

Overview

Swift Server

Introduction

This is very rough and basic HTTP server written in Swift without using Foundation.

This is partially based on the Swifter repo, however, the point is to eliminate the need for Apple's Foundation library to prepare for using Swift on Linux.

This is built using Swift Script Include to enable using multiple files for Swift scripts and runs without Xcode purely on the terminal.

Installation Notes

This is built using Swift 2, and requires your command-line swift to be using Swift 2 as well. You can check your Swift version by running swift --version in your terminal. If you are running Swift 1.2 instead of 2.0, first, make sure that you have the Xcode 7 beta installed. Next, run the following command:

sudo xcode-select -switch /Applications/Xcode-beta.app/Contents/Developer

Running

To run the project, simply type make run in the project directory.

Visit http://127.0.0.1:3000 in your web browser to see a friendly "Hello, World!" message. The HTTP request will be printed in your terminal.

Example Code

The functionality is currently very basic. The code below shows what the server can currently do.

include "lib/server.swift"

let app = Server(port: port)

app.run() {
    request, response -> () in
    print(request.raw)
    response.sendRaw("HTTP/1.1 200 OK\n\nHello, World!\n")
}

You might also like...
Displaying very large images in limited memory environments

LargeImageDownsizing in Swift displaying very large images in limited memory environments by turning a large image on disk into a smaller image in mem

SwiftlyNetworker - very Ez Netowkrer!! 🧑‍💻

SwiftlyNetworker Example To run the example project, clone the repo, and run pod install from the Example directory first. Installation SwiftlyNetwork

Fizz Buzz is a very simple programming task, asked in software developer job interviews.

FizzBuzz Fizz Buzz is a very simple programming task, asked in software developer job interviews. A typical round of Fizz Buzz can be: Write a program

CoreNetwork module with the basic functionality of requests to the network

CoreNetwork module with the basic functionality of requests to the network

Elegant HTTP Networking in Swift
Elegant HTTP Networking in Swift

Alamofire is an HTTP networking library written in Swift. Features Component Libraries Requirements Migration Guides Communication Installation Usage

Swift HTTP for Humans
Swift HTTP for Humans

Just is a client-side HTTP library inspired by python-requests - HTTP for Humans. Features Just lets you to the following effortlessly: URL queries cu

Versatile HTTP Networking in Swift
Versatile HTTP Networking in Swift

Net is a versatile HTTP networking library written in Swift. 🌟 Features URL / JSON / Property List Parameter Encoding Upload File / Data / Stream / M

🏇 A Swift HTTP / HTTPS networking library just incidentally execute on machines
🏇 A Swift HTTP / HTTPS networking library just incidentally execute on machines

Thus, programs must be written for people to read, and only incidentally for machines to execute. Harold Abelson, "Structure and Interpretation of Com

Swift/Obj-C HTTP framework with a focus on REST and JSON

Now Archived and Forked PMHTTP will not be maintained in this repository going forward. Please use, create issues on, and make PRs to the fork of PHMT

Owner
Cezary Wojcik
Keyboard Wizard
Cezary Wojcik
Http - Demo for Http Layer

http Example To run the example project, clone the repo, and run pod install fro

null 0 Jan 24, 2022
A Swift web framework and HTTP server.

A Swift Web Framework and HTTP Server Summary Kitura is a web framework and web server that is created for web services written in Swift. For more inf

Kitura 7.6k Jan 6, 2023
Tiny http server engine written in Swift programming language.

What is Swifter? Tiny http server engine written in Swift programming language. Branches * stable - lands on CocoaPods and others. Supports the latest

null 3.6k Dec 31, 2022
Super lightweight async HTTP server library in pure Swift runs in iOS / MacOS / Linux

Embassy Super lightweight async HTTP server in pure Swift. Please read: Embedded web server for iOS UI testing. See also: Our lightweight web framewor

Envoy 540 Dec 15, 2022
Swift HTTP server using the pre-fork worker model

Curassow Curassow is a Swift Nest HTTP Server. It uses the pre-fork worker model and it's similar to Python's Gunicorn and Ruby's Unicorn. It exposes

Kyle Fuller Archive 397 Oct 30, 2022
A simple GCD based HTTP client and server, written in 'pure' Swift

SwiftyHTTP Note: I'm probably not going to update this any further - If you need a Swift networking toolset for the server side, consider: Macro.swift

Always Right Institute 116 Aug 6, 2022
libuv base Swift web HTTP server framework

Notice Trevi now open a Trevi Community. Yoseob/Trevi project split up into respective Trevi, lime, middlewares and sys packages at our community. If

leeyoseob 46 Jan 29, 2022
A simple HTTP server written in Swift

http4swift http4swift is a tiny HTTP server library for Nest-compatible applications. This project is unstable, and the API might be changed at anytim

Shun Takebayashi 27 Jun 29, 2022
Lightweight, flexible HTTP server framework written in Swift

Hummingbird Lightweight, flexible server framework written in Swift. Hummingbird consists of three main components, the core HTTP server, a minimal we

Hummingbird 245 Dec 30, 2022
FlyingFox - a lightweight HTTP server built using Swift Concurrency

Usage Credits Introduction FlyingFox is a lightweight HTTP server built using Swift Concurrency. The server uses non blocking BSD sockets, handling ea

Simon Whitty 262 Dec 24, 2022