xcode 在 iOS 设备上运行网络服务器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8417321/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:42:16  来源:igfitidea点击:

Run a webserver on an iOS device

objective-ciosxcodehttp

提问by Besi

I want to create an App that can share files between other iOS devices and potentially also Desktop computers.

我想创建一个可以在其他 iOS 设备和台式计算机之间共享文件的应用程序。

So what I want to do is run a lightweight web server on my device that allows to download files from the device like so:

所以我想要做的是在我的设备上运行一个轻量级的网络服务器,允许从设备下载文件,如下所示:

http://myphone.local:1234/folder/samplefile.txt

http://myphone.local:1234/folder/samplefile.txt

How can I provide such a server on a non-jailbroken device. I would prefer not to write a server like this from scratch :-).

如何在非越狱设备上提供这样的服务器。我不想从头开始编写这样的服务器:-)。

Thanks a lot for your help

非常感谢你的帮助

回答by tilo

回答by Foo

According to the GitHub project:

根据GitHub 项目

CocoaHTTPServer is a small, lightweight, embeddable HTTP server for Mac OS X or iOS applications.

Sometimes developers need an embedded HTTP server in their app. Perhaps it's a server application with remote monitoring. Or perhaps it's a desktop application using HTTP for the communication backend. Or perhaps it's an iOS app providing over-the-air access to documents. Whatever your reason, CocoaHTTPServer can get the job done.

CocoaHTTPServer 是适用于 Mac OS X 或 iOS 应用程序的小型、轻量级、可嵌入的 HTTP 服务器。

有时开发人员需要在他们的应用程序中嵌入一个 HTTP 服务器。也许它是一个带有远程监控的服务器应用程序。或者它可能是一个使用 HTTP 作为通信后端的桌面应用程序。或者它可能是一个 iOS 应用程序,提供对文档的无线访问。无论您出于何种原因,CocoaHTTPServer 都可以完成工作。