NanoHTTPD

HTTPS Server on Android Device Using NanoHttpd

試著忘記壹切 提交于 2019-12-02 19:49:48
I am trying to run an HTTPS Server on an Android device using NanoHttpd (my final goal is to run WSS server on Android). I successfully ran HTTP Server and Websocket using NanoHttpd on Android. I generated the key on MAC using this command and copied it onto my device: keytool -genkey -keystore key.keystore -storepass keypass -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider I wrote the following code: keyStore = KeyStore.getInstance("BKS"); keyStore.load(stream, keyStorePwd.toCharArray()); keyManagerFactory = KeyManagerFactory .getInstance(KeyManagerFactory

Android, NanoHttpd and Local jQuery reference

早过忘川 提交于 2019-12-02 16:29:36
问题 I am in the early stages of putting together an Android app that will host an assets based "website" using NanoHttpd. The app will rely heavily on the jquery library. I am using this NanoHttpd.java file and have successfully hosted and accessed a html file. My problem is that I cannot seem to be able to include a local copy of the jquery library. If I reference a cdn hosted copy, everything works just as it should. If I place a copy of the library in the assets directory, the html of the page

Android, NanoHttpd and Local jQuery reference

旧巷老猫 提交于 2019-12-02 12:37:34
I am in the early stages of putting together an Android app that will host an assets based "website" using NanoHttpd. The app will rely heavily on the jquery library. I am using this NanoHttpd.java file and have successfully hosted and accessed a html file. My problem is that I cannot seem to be able to include a local copy of the jquery library. If I reference a cdn hosted copy, everything works just as it should. If I place a copy of the library in the assets directory, the html of the page displays correctly in the browser however, I receive the following error in the javascript console of

How do I serve external css, jpg and gif files from Nanohttpd (Nanohttpd run on a normal pc not on Android)?

核能气质少年 提交于 2019-12-01 11:09:22
In index.html, External css is used and paths to image src are used to request css images from a folder. However the images are not loaded and css style is not applied to the page. import java.io.*; import java.util.*; /** * An example of subclassing NanoHTTPD to make a custom HTTP server. */ public class HelloServer extends NanoHTTPD { public HelloServer() throws IOException { super(8080, new File(".")); } public Response serve(String uri, String method, Properties header, Properties parms, Properties files) { BufferedReader br = null; String msg=""; try { String sCurrentLine; br = new

How do I serve external css, jpg and gif files from Nanohttpd (Nanohttpd run on a normal pc not on Android)?

 ̄綄美尐妖づ 提交于 2019-12-01 08:39:39
问题 In index.html, External css is used and paths to image src are used to request css images from a folder. However the images are not loaded and css style is not applied to the page. import java.io.*; import java.util.*; /** * An example of subclassing NanoHTTPD to make a custom HTTP server. */ public class HelloServer extends NanoHTTPD { public HelloServer() throws IOException { super(8080, new File(".")); } public Response serve(String uri, String method, Properties header, Properties parms,

NanoHTTPD. Cache InputStream to file and continue streaming

∥☆過路亽.° 提交于 2019-11-30 04:53:53
问题 I want to cache data while playing it in MediaPlayer. As I read, there is one way to do it - create own local http server and set local url to MediaPlayer's setDataSource(String path). I am using NanoHTTPD as a local server. There is code of serve function: @Override public Response serve(String uri, Method method, Map headers, Map parms, Map files) { try { // delete / character URL url = new URL(uri.substring(1)); URLConnection connection = url.openConnection(); connection.connect(); File

File Directory Navigation with Android Nanohttpd lightweight server

非 Y 不嫁゛ 提交于 2019-11-29 13:11:51
With the code below, i was able to create a mobile server on android phone with the Nanohttpd lightweight server. The code basically loop through the root directory of the host android device and list both files and folders as links. What i want to implement is when a user clicks on any of the link (the folder links), the browser should display the files and folder contained in the clicked folder link. How do i do this as i can not find any Nanohttpd documentation for beginners. import java.io.File; import java.util.Map; import android.annotation.SuppressLint; import android.app.Activity;

Why images and style files couldn't found on NanoHTTPD

混江龙づ霸主 提交于 2019-11-29 10:23:21
问题 PROBLEM : I'm using NanoHTTPD . It's working great but it's not serving .js files, images and others. DETAILED EXPLANATION : i have a pages folder inside of assets folder. This folder containing index.html , css files, images and others. I'm using NanoHTTPD like this, but when i browse with my browser, there aren't any styles or images. Server can't found images and other files. There is only index.html file's content. Activity : MyHTTPD server = null; try { server = new MyHTTPD

File Directory Navigation with Android Nanohttpd lightweight server

♀尐吖头ヾ 提交于 2019-11-28 06:42:58
问题 With the code below, i was able to create a mobile server on android phone with the Nanohttpd lightweight server. The code basically loop through the root directory of the host android device and list both files and folders as links. What i want to implement is when a user clicks on any of the link (the folder links), the browser should display the files and folder contained in the clicked folder link. How do i do this as i can not find any Nanohttpd documentation for beginners. import java

How to serve a file on sdcard using NanoHTTPD (inside Android)

依然范特西╮ 提交于 2019-11-28 04:34:44
I've written a small Android server using NanoHTTPD. It can serve an HTML file well (web page located at sdcard/www/index.html). Can anybody please help me find out how can I serve an audio or video file instead of an html page using NanoHTTPD? Forgive me if the question seems silly, as I'm new to HTTP! Here is my server side code (I've replaced the webpage path to that of an audio file): package com.example.zserver; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.Map; import android.app.Activity; import android.os