Code Monkey home page Code Monkey logo

android-web-server's Introduction

Android Web Server (FireFly)

Simple and Small footprint TCP/IP Web Server for Android in Java

This is standalone, multithreaded, almost or No dependancy ! http server in Java with example use in Android.

Features supported

  • Support basic GET, POST requests
  • Render html files
  • Render jpeg,png,gif
  • Custom api for dynamic web pages (mvc)
  • Support javascript rendring
  • Multithreaded, support mulitple client

What it does not do?

  • File upload, video rendering

Getting Started

How to use it in Android?

  1. Copy TinyWebServer.java class from src dir to your android project package

  2. Call following from android service or process

    @Override
    protected void onCreate(Bundle savd){
         super.onCreate(savd);
         ...
        //call contructor with local ip, port , public html directory path
        TinyWebServer.startServer("localhost",9000, "/web/public_html");
    }
    
    @Override
    public void onDestroy(){
        super.onDestroy();
         //stop webserver on destroy of service or process
         TinyWebServer.stopServer();
    }

How to write custom api?

  1. Copy AppApis.java from src directory

  2. keep the package name same for AppApis.java like "appapis.queryfiles"

  3. open AppApis.java and write your own mehtod/function inside AppApis.java for example,

    public String myfirstapi(HashMap qparms){
      //todo - write your api logic here
      //qparms is collection of GET and POST parameters
    }

    you can access this api -> http://localhost:9000/myfirstapi

How to check demo?

  • Run the code and hit browser with http://localhost:9000/helloworld
  • here port number is 9000
  • localhost or your device ip address
  • helloworld is api method inside AppApis.java

Demo ScreenShot

Design, Build, Tested by
twitter , github /@sonuauti

android-web-server's People

Contributors

sonuauti avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.