如何在 android 本地搭建一个 http http流媒体服务器搭建

如何在android平台下搭建Tomcat本地服务器
[问题点数:20分]
如何在android平台下搭建Tomcat本地服务器
[问题点数:20分]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
匿名用户不能发表回复!|如何在 android 本地搭建一个 http 服务器_百度知道
如何在 android 本地搭建一个 http 服务器
我有更好的答案
然后保存就行了!吼吼,于是下一个想法就是能不能在手机上搭建一个WEB环境?:下载我提供的集成环境的APK文件(这里)解压密码:.首先在手机上安装APK,IP地址填写你手机WIFI的IP地址,保存??
  想到就开始各种搜,发现安卓使用的Linux并不属于任何发行版本,废物利用,数据更安全,便携,够你折腾了:安卓底层不也是Linux么,免费试用55年,就能够看到mysql启动和相应信息了。
  2。下载成功后。
  第三,省电省资源,至少600MHZ的CPU,256内存,手机需要ROOT。登录你的路由器,请关闭;,选择&ldquo,点登录  这一阵感觉玩手机玩腻了,VPS也玩腻了,瞬间感觉啥都玩腻了。前几天闲着无聊,看到了手机上的超级终端,心想,然后会提示重启,集成环境的APK也有了:装13;,端口填写80,KSWEB在谷歌商店里是收费的,就剩下公网访问了。
  第一:需要一部安卓手机,首次开启,会解压缩文件,账号密码就是你oray的通行证。
  第二,可以在手机浏览器里输入127.0.0.1,就可以看到相关信息。虽然版本有些老,但是相当简便啊亲&&
  如果你只想在手机上测试,重启后,点击&转发规则&rdquo?于是就用超级终端wget了一个文件;虚拟服务器&&hellip,点击&动态DNS设置&,就会自动识别你的免费域名。如图所示,直接输入域名就可以访问到手机了,如图所示。
  4,哈哈,这下好了,发现谷歌商店里有一个集成lighttpd+php+mysql+phpmyadmin环境的APK,毫不客气的说,这绝对是全网首发,所以,经过我各种搜。
  这样的话,终于有了这一篇文章,(如果手机里有什么防火墙之类的,成功了,至少不用让你再像我一样各种搜了:需要一个支持路由功能的路由器,以及一个花生壳账号。
  1。如果想让公网访问手机,
  那么就需要使用DDNS(动态域名解析)来支持。
  3,够折腾,看来使用传统的建站方式不行了。继续搜索:
  至此,你的手机就可以当成一个独立的VPS来使用了,建议使用闲置的手机来玩,它有以下几个好处,免费试用5天,我提供的这个文件为网友破解版。当然,如果只装上这个APK只能在本地测试,无法使用公网访问。下面是我的演示;还有,查域名的时候貌似是独立IP,这样百度会不会喜欢呢.使用oray护照,登录花生壳,系统会自动分配给你一个免费域名,用这个域名来访问手机.保存后,国内速度一流&hellip,如果成功了,只要你的路由器不关闭,就可以一直使用了,然后点开KSWEB.5G,2G内存的手机,这几乎能满足像我这样的小站的需求了。硬件有了,那么到这里就结束了.点options进入设置,然后勾选上root权限,这样就可以更改端口为80了。然后回到主界面,点phpmyadmin然后就会自动下载了,没有ROOT的话,不能使用80端口,否则不能使用WIFI地址访问)。
  现在的手机硬件已经很强大了,¥1999就能买到4核1
为您推荐:
其他类似问题
您可能关注的内容
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。Android学习之——自己搭建Http框架(1)
最近学习http框架。
目前写的这个框架暂时只适用于学习之用,实际用于项目之中还需要不断的优化。
要从服务器或者网络获取数据,显示到UI上面,网络请求的操作不能放在UI线程中进行,android为我们封装了AsyncTask类来进行异步的请求操作,所以这个Http框架基于AsyncTask。
二、框架主要类
定义Request类,定义url,服务器返回数据,post的请求params,下载进度等参数。
定义HttpUtil类来封装http请求代码。在里面定义execute()方法,该方法判断是get还是post,然后再去call get(),post() 方法。post() 请求需要的参数在Request中设置.
在AsyncTask中,doingBackground()方法中 execute http,将返回的数据写到内存中变成String返回,如果数据较大,可以先存到文件中,把path返回,在不同的callback中处理。
三、框架搭建
1. 首先,我们建立 HttpClientUtil.java 类,用于处理HTTP的get和post,里面定义execute()方法,该方法判断是get还是post,然后再去call get(),post() 方法,post()
请求需要的参数在Request中设置.:
* @author Mr.傅
public class HttpClientUtil {
* 执行HTTP方法,Request 设置请求类型
* @param request
* @throws Exception
public static HttpResponse excute(Request request) throws Exception{
switch (request.requestMethod) {
return get(request);
case POST:
return post(request);
//这里没有定义 DELETE 和 PUT 操作
throw new IllegalStateException("you doesn't define this requestmethod");
private static HttpResponse get(Request request) throws Exception {
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(request.url);
addHeader(get, request.headers);
//返回的结果放到上一层进行处理
HttpResponse response = client.execute(get);
private static HttpResponse post(Request request) throws Exception {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(request.url);
addHeader(post, request.headers);
//post的请求参数在 Request 中定义,如果为空,则没有定义
if (request.entity == null) {
throw new IllegalStateException("you forget to set post content to the httpost");
post.setEntity(request.entity);
HttpResponse response = client.execute(post);
* @param request
* @param headers
public static void addHeader(HttpUriRequest request, Map headers){
if (headers != null && headers.size() > 0 ) {
for(Entry entry : headers.entrySet()){
request.addHeader(entry.getKey(), entry.getValue());
2. 上述代码中的 Request.java 类,定义url,服务器返回数据,post的请求params,下载进度等参数定义如下:/**
* @author Mr.傅
public class Request {
public enum RequestMethod{
GET,POST,DELETE,PUT
RequestMethod requestM
* Http请求参数的类型,包括表单,string, byte等
public HttpE
public Map
public static final String ENCODING = "UTF-8";
* 设置回调接口,该接口中的onSuccess和onFilure方法需要在体现在UI线程当中
private RequestT
public Request(String url, RequestMethod method) {
this.url =
this.requestMethod =
public void setEntity(ArrayList forms){
entity = new UrlEncodedFormEntity(forms, ENCODING);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
public void setEntity(String postContent){
entity = new StringEntity(postContent, ENCODING);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
public void setEntity(byte[] bytes){
entity = new ByteArrayEntity(bytes);
* 设置回调方法,在ui线程中定义需要请求 返回的 方法
* @param callback
public void setCallback(ICallback callback) {
this.callback =
* UI线程中,执行该方法,开启一个AsyncTask,注意AsyncTask每次使用必须重新new
public void execute() {
task = new RequestTask(this);
task.execute();
3. ICallback接口,该接口的onFilure和onSuccess方法在UI线程当中实现,如果在RequestTask中doInBackground中HttpResponse返回成功则在onPostExecute中调用onSuccess,否则调用onFilure,并传递已经解析了的返回参数:public interface ICallback {
void onFilure(Exception result);
void onSuccess(Object result);
* 将从服务器得到的HttpResponse进行解析,解析完成以后,返回给UI线程
Object handle(HttpResponse response);
4. RequestTask 继承自 AsyncTask ,在doInBackground 进行HTTP请求,同时对HTTP请求返回的数据结果进行解析,通过调用callback中的handle方法,解析HTTP请求返回的参数,返回后的结果(如果抛出异常,将异常也返回),在onPostExecute中进行处理,调用不同的方法,返回到UI线程,代码如下:
* @author Mr.傅
* @version create time:日 下午2:19:39
public class RequestTask extends AsyncTask {
public RequestTask(Request request) {
this.request =
protected Object doInBackground(Object... params) {
HttpResponse response = HttpClientUtil.excute(request);
//response 解析代码放到对应的类中,对应handle中的bindData方法
return request.callback.handle(response);
} catch (Exception e) {
protected void onPostExecute(Object result) {
super.onPostExecute(result);
if (result instanceof Exception) {//失败
request.callback.onFilure((Exception)result);
}else {//成功
request.callback.onSuccess(result);
5. AbstractCallback.java 该类 中实现接口 ICallback 的 handle 方法,该方法主要作用是,对HTTP返回的HttpResponse 进行解析,如果返回状态码是200,则进行下一步处理;如果UI调用了setPath()方法,设置了保存的路径的话,就将HTTP返回的数据先写入到文件中,然后文件中读取出来,放入到对应的解析实现类中,如:StringCallback,JsonCallback等,
返回到doInBackground 中(doInBackground 中的return request.callback.handle(response)步骤)。如果没有设置路径,则直接调用bindData(EntityUtils.toString(entity)),
放入到具体的Callback中进行处理,然后返回到doInBackground中进行下一步处理。/**
* @author Mr.傅
public abstract class AbstractCallback implements ICallback{
* 文件存放的路径
private static final int IO_BUFFER_SIZE = 4*1024;
public Object handle(HttpResponse response){
// file, json, xml, image, string
int statusCode = -1;
InputStream in =
HttpEntity entity = response.getEntity();
statusCode = response.getStatusLine().getStatusCode();
switch (statusCode) {
case HttpStatus.SC_OK:
if (TextUtil.isValidate(path)) {
//将服务器返回的数据写入到文件当中
FileOutputStream fos = new FileOutputStream(path);
if (entity.getContentEncoding() != null) {
String encoding = entity.getContentEncoding().getValue();
if (encoding != null && "gzip".equalsIgnoreCase(encoding)) {
in = new GZIPInputStream(entity.getContent());
} if (encoding != null && "deflate".equalsIgnoreCase(encoding)) {
in = new InflaterInputStream(entity.getContent());
in = entity.getContent();
byte[] b = new byte[IO_BUFFER_SIZE];
while ((read = in.read(b)) != -1) {
// TODO update progress
fos.write(b, 0, read);
fos.flush();
fos.close();
in.close();
//写入文件之后,再从文件当中将数据读取出来,直接返回对象
return bindData(path);
// 需要返回的是对象,而不是数据流,所以需要去解析服务器返回的数据
// 对应StringCallback 中的
//2. 调用binData
return bindData(EntityUtils.toString(entity));
} catch (ParseException e) {
//这些异常处理都没有进行操作,后面的文章会再做处理
} catch (IOException e) {
* 数据放入到不同的Callback中处理
protected Object bindData(String content){
//StringCallback等方法中实现了该方法
* 如果要存入到文件,则设置文件路径
public AbstractCallback setPath(String path){
this.path =
6. StringCallback.java 目前的代码,只实现了该callback,JsonCallback,PathCallback,会在后面的文章当中具体实现:public abstract class StringCallback extends AbstractCallback {
protected Object bindData(String content) {
//如果路径存在,则重新讲数据从文件中读取出来
if (TextUtil.isValidate(path)) {
return IOUtiliteies.readFromFile(path);
7. 当中用到的TextUtil.java 类 public class TextUtil {
public static boolean isValidate(String content){
return content != null && !"".equals(content.trim());
public static boolean isValidate(ArrayList content){
return content != null && content.size() > 0;
8. UI线程中具体调用方法如下:private void requestString() {
//设置保存路径
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "mrfu_http.txt";
Request request = new Request("https://www.baidu.com", RequestMethod.GET);
request.setCallback(new StringCallback() {
public void onSuccess(Object result) {
mTestResultLabel.setText((String)result);
public void onFilure(Exception result) {
result.printStackTrace();
}.setPath(path));
request.execute();
其中mTestResultLabel 是TextView
可以看到实现效果,这里我们在SD卡的根目录下将返回结果存入到了 "mrfu_http.txt" 文件中,同时显示到了 UI 上面:如图所示:
源码下载:https://download.csdn.net/detail/fu222cs98/7377683
欢迎转载,转载注明出处,谢谢
Mr.傅:Stay利用ESP8266搭建你的Web服务器+安卓app客户端_Arduino入门与进阶
利用ESP8266搭建你的Web服务器+安卓app客户端
作者:duino123.com
本项目利用一块ESP8266搭建一个独立的web服务器,可以用来开关2个LED灯。当然,这仅仅是抛砖引玉,你可以扩展出更多的应用。
PLCLIVE.COM注:
本项目利用一块ESP8266搭建一个独立的web服务器,可以用来开关2个LED灯。当然,这仅仅是抛砖引玉,你可以扩展出更多的应用。
1. 将NodeMCU烧录进你的ESP8266模块
NodeMCU&is a firmware that allows you to program the ESP8266 modules with LUA script. And you&ll find it very similar to the way you program your Arduino. With just a few lines of code you can establish a WiFi connection, control the ESP8266 GPIOs, turning your&ESP8266 into a web server&and a lot more.
2. 原理图 (3.3V FTDI编程器)
CH_PD -& 3.3V
GPIO 0 -& GND
VCC -& 3.3V
GND -& GND
3. 下载NodeMCU Flasher软件
After wiring&your circuit, you have to download the NodeMCU flasher. It's a&.exe&file that you can download using one of the following links:
Windows Flasher
&Windows Flasher
You can click&&to find all the information about NodeMCU flasher.
4. 烧录ESP8266
Open the flasher that you just downloaded and a window should appear (as shown in the following figure).
Press the button &Flash& and it should start the flashing process immediately (You might have to change some of the settings &on the Advanced&tab). After finishing this process, it should&appear a green circle with a check icon.
Now follow the schematics bellow to create your web server to control two LEDs.
6. 修改和上传代码
I recommend using the ESPlorer program created by 4refr0nt&to create and save LUA files into your&ESP8266. Follow these instructions to download and install ESPlorer:
下载ESPlorer软件
Unzip that folder
Go to the&dist&folder (here's the path:&ESPlorer-master\ESPlorer\dist)
Run&ESPlorer.jar.&It's a JAVA program, so you need JAVA installed on&your computer.
Open the ESPlorer
You should see a window similar to the preceding Figure, follow these instructions to upload a LUA&file:
Connect your FTDI programmer to your computer
Select your FTDI programmer&port
Press&Open/Close
Select&NodeMCU+MicroPtyhon tab
Create a new file called&init.lua
Press&Save to ESP
Everything that you need to worry about or change is highlighted in red box.
Upload the following code into your ESP8266 using the preceding software. Your file should be named &init.lua&.
Don't forget to replace your WiFi Station details in that code above (Network Name and Password).
8. 访问你搭建的服务器
When your ESP8266 restarts&it prints in your serial monitor&the IP address of your ESP8266. If you type your ESP8266&IP address in your web browser, you can access your web server. In my case it's http://192.168.1.95.
9. 延伸 &编写安卓APP访问8266服务器
在App Inventor中创建安卓APP(国内直接访问:,有不明白的就加qq群交流吧 )
MIT App Inventor is a&drag-and-drop software that allows you to create&a basic, but fully functional Android app within an hour or less.
Here&s how to edit the ESP8266 Controller app:
Unzip the folder
Click the &Create Apps& button on the top right corner
Go to the &Projects& tab and select &Import project (.aia)&
After importing the .aia file, you'll be able to edit the app and&see how the app was built.
The designer tab is where you can edit how the app looks. Feel free to change the text, change the colors, add buttons or add more features.
The blocks section is where you can add what each button does and add logic&to your app.
After finishing editing the app&you can click the &Build& app tab and install the .apk file&in your Android. &I personally recommend that you first upload the app provided below to ensure that everything works as expected (later you can edit the app).
Follow these instructions to install the default app that I've created:
&由于国内网络的限制,访问谷歌需要特殊方式,你懂的
Unzip the folder
Move the .apk file to your Android phone
Run the .apk file to install the app
Here&s how the&ESP8266 Controller&app looks when you to open it.
It's very easy to configure. Click the button&Set IP Address& on the bottom of the screen and type your IP address (in my case 192.168.1.95).
Now you can turn&the GPIOs high and low with your smartphone.&
继续延伸....
This is a basic example that shows you how easy it is to integrate an Android app with the ESP8266. You can take this example and modify it.
You could add multiple screens to the app, so you can other ESPs or add buttons to control more GPIOs.
如需更详细资料,如有好资源分享,请加入QQ交流群:
欢迎阅读,欢迎转载,不用注明出处!本站只提供入门和进阶资料,做您学习的小伙伴!请加群:
ESP8266使用指南(基于AT指令 NodeMCU 固件ESP-12E)
如何在Arduino平台上利用MFRC522 RFID实现安全访问
ESP8266 ESP-12新手指南
[转]Arduino ESP8266调试笔记
自动化世界拒绝访问 | www.ggdoc.com | 百度云加速
请打开cookies.
此网站 (www.ggdoc.com) 的管理员禁止了您的访问。原因是您的访问包含了非浏览器特征(407c3fca9c184382-ua98).
重新安装浏览器,或使用别的浏览器}

我要回帖

更多关于 http下载服务器搭建 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信