Swift的简单HTTP实现:Swift HTTP Server
dfd7
9年前
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