Swift的簡單HTTP實現:Swift HTTP Server

dfd7 9年前發布 | 15K 次閱讀 Apple Swift開發 Swift HTTP Server

Swift的簡單HTTP實現,使用POSIX socket API。可運行在 Mac OS X 和Linux之上。

For Mac users: You can install new Swift compiler following this instruction then you will be able to build the code directly on your Xcode.

Compile

Run the following command to compile the source:

swift build

Run

After successfully compile, run the server with:

.build/debug/swift-http

Now, go to http://localhost:8080 to test, the response should be:Hello World


Setting up Docker container from Dockerfile

Go todockerfolder and runbuild.shto buildswiftboximage

cd docker
./build.sh

Run new container fromswiftboximage, mount your working directory and expose the port:

docker run -it -p 8080:8080 -v /path/to/your/host/working/folder:/src swiftbox

Now you can go to/srcfolder, which linked to your/path/to/your/host/working/folderto start using:

cd /src
swift build

項目主頁:http://www.baiduhome.net/lib/view/home/1449389342402

 本文由用戶 dfd7 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!