Skip to main content

An easy to use Web interface for python application.

Project description

Web-CLI

Easy to use Web CLI for python applications.

Table of content

Usage

Import and make a instantiate it.

settings = Settings(name="Example page")
server = WebCLIServer(settings, backend)

fun backend(user_command: UserCommand) -> None:
    # do stuff here

After, start the server with server.start().

server.start()

The example provded will result in a webserver opened on 127.0.0.1:8080 (localhost:8080). Opening this page will result in a command line looking webpage that can communicate with the server.

Settings

  • host: Host's IP.
  • port: Port for the IP address.
  • name: Name of the web server.

functions

to_file

  • string_path (str or None): A string path for the settings file.

Creates a config file with the path provided or in the current folder witht he default name.

from_file

  • string_path (str or None): A string path for the settings file.

Reads the file provided, and creates a settings class.

WebCLIServer

  • settings: Settings data to set up the server.
  • backend: A func that can handle UserCommand data class as input, and do something with it, with a return value that's ignored.
  • logger: An smdb_logger logger. It can be None or ignored, so it won't produce output on stdrout.

functions

push_data

  • response (str or List[str]): The output for a user command.
  • command (UserCommand or None): The user command to reply to. If None, the last command will be used.

Adds a response for a user command. It can be used to oush data to the web cli, with command being not set, it will result in the data being pushed to the last command in the history.

start

Starts the server.

stop

Stops the server.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smdb_web_interface-0.1.5.tar.gz (14.2 kB view hashes)

Uploaded Source

Built Distribution

smdb_web_interface-0.1.5-py3-none-any.whl (13.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page