Skip to content

Saros72/PyServe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

153 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PyServe πŸš€

Android application with a local Python server and plugin system


πŸ“± About

PyServe is an Android application that runs a local Python server (built with Bottle) directly on the device and allows dynamic loading of plugins.

It is designed as a lightweight mobile backend framework for testing, prototyping, and local API development.


βš™οΈ How it works

  • The app starts a local server at: http://127.0.0.1:9666
  • Backend is built using Bottle
  • On startup, the application scans the plugin directory
  • Each plugin is dynamically imported using Python import system
  • Plugins can extend server functionality (routes, logic, APIs)

πŸ”Œ Plugin system

Plugins are located at:

/storage/emulated/0/PyServe/

Each plugin is a separate folder:

PyServe/
 β”œβ”€β”€ demo/
 β”‚   └── default.py
 └── my_plugin/
     └── main.py

πŸ”Œ Plugins repository

Official plugin collection for PyServe:

πŸ‘‰ PyServe Plugins

Contains:

  • ready-to-use plugins
  • streaming providers
  • web scrapers
  • integrations for external applications (e.g. Streamlet)

Plugins can be placed into: /storage/emulated/0/PyServe/

πŸ“¦ Demo plugin

The application automatically creates a demo plugin on first launch.

  • Located in: /storage/emulated/0/PyServe/demo/
  • File: default.py

🌐 Demo endpoint

The demo plugin provides a basic example endpoint available at:

http://127.0.0.1:9666/demo

This allows you to immediately verify that the server is running correctly.

You can open it directly using the web button inside the app.


πŸ“¦ Plugin structure

Each plugin must include:

  1. Entry file:
  • main.py (recommended)
  • or default.py (fallback)
  1. Optional function:
def register(app):
    pass

This function is called when the plugin is loaded.


🧠 How plugin loading works

  • The app scans the plugin directory
  • Each folder is treated as a separate plugin
  • Python files are loaded via importlib
  • Plugin errors:
    • are shown in the UI log
    • are written to an error log file
    • do NOT crash the main application

🌐 Server

Runs locally at: http://127.0.0.1:9666

Built using:

  • Bottle (routing and API)
  • Python standard library

πŸ“Œ Allowed Python modules in plugins

You can use:

βœ” Standard library

  • json
  • time
  • os
  • threading
  • datetime

βœ” Additional modules

  • beautifulsoup4
  • websocket-client
  • m3u8

βœ” Server / networking

  • bottle
  • requests

πŸ“± Android requirements

To ensure the app works correctly on Android:

πŸ” Permissions

  • You must allow "All files access"
  • Required because plugins are stored in: /storage/emulated/0/PyServe/

βš™οΈ Foreground service

  • Server runs as a foreground service
  • Prevents Android killing it in background
  • Persistent notification is shown while running

πŸ”‹ Battery optimization

  • Disable battery optimization for best stability
  • Otherwise Android may stop the server

⚠️ Important notes

  • Plugins run in the same Python runtime as the app
  • Broken plugin does NOT crash the server
  • Errors are isolated and logged
  • Intended for local development use only

πŸ“‚ Project structure

PyServe/
 β”œβ”€β”€ main.py
 β”œβ”€β”€ plugin_loader.py
 β”œβ”€β”€ service.py (Bottle backend)
 β”œβ”€β”€ ui/
 β”‚    └── layout.kv
 β”œβ”€β”€ assets/
 └── /storage/emulated/0/PyServe/
      β”œβ”€β”€ demo/
      └── plugins...

πŸ“± Features

  • Start / stop local server
  • Plugin system with dynamic loading
  • Error isolation per plugin
  • UI logging system
  • Android foreground service support
  • Open local web interface
  • Built-in WebDAV server (file transfer over LAN)

πŸ“¦ WebDAV server

PyServe includes a built-in WebDAV server running on:

http://127.0.0.1:9667/

What is it for?

  • upload plugins to another device (e.g. Android TV)
  • transfer files over local network
  • access storage without USB cables

Recommended clients

  • MiXplorer (Android)
  • Solid Explorer
  • other WebDAV-compatible file managers

Example usage

  1. Open file manager on another device (e.g. Android TV)
  2. Add new WebDAV connection
  3. Enter your device IP: http://YOUR_IP:9667/
  4. Browse and upload files directly

Tip

Use it to quickly deploy plugins without rebuilding the app.

Notes

  • Works only on the same local network (LAN)
  • No additional setup required

πŸ§ͺ Example plugin

def register(app):

    @route("/hello")
    def hello():
        return "Hello from plugin!"

πŸ”₯ Use cases

  • Local API testing on Android
  • Backend prototyping
  • Plugin-based architecture experiments
  • Offline server tools
  • Learning Bottle and Python web servers

🎬 Demo

Short demonstration of the app running on Android device (plugin loading, UI, and local server).

Watch the video

About

Android local Python server with plugin system (Bottle + KivyMD)

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors