Giter Club home page Giter Club logo

click-web's Introduction

click-web

Serve click scripts over the web with minimal effort.

Example screenshot

Usage

See this demo screen capture.

Take an existing click script, like this one:

example_command.py

import click
import time

@click.group()
def cli():
    'A stupid script to test click-web'
    pass

@cli.command()
@click.option("--delay", type=float, default=0.01, help='delay for every line print')
@click.argument("lines", default=10, type=int)
def print_rows(lines, delay):
    'Print lines with a delay'
    click.echo(f"writing: {lines} with {delay}")
    for i in range(lines):
        click.echo(f"Hello row: {i}")
        time.sleep(delay)

if __name__ == '__main__':
    cli()

Create a minimal script to run with flask

app.py

from click_web import create_click_web_app
import example_command

app = create_click_web_app(example_command, example_command.cli)

Running example app:

In Bash:

export FLASK_ENV=development
export FLASK_APP=app.py
flask run

Caution: If you plan to serve publicly make sure you setup security (SSL, login etc.) See Authentication

Authentication

For an example of how to secure using http digest auth see the auth example.

Note: There is no permission system and all logged in users can access everything. If you plan to deploy in an open environment make sure to setup HTTPS.

Custom Styling

For an example of how to customize styling using CSS and add extra page head or footer see the custom example.

Unsupported click features

It has only been tested with basic click features, and most advanced features will probably not work.

  • Variadic arguments of file and path type
  • Promts (probably never will)
  • Custom ParamTypes (depending on implementation)

TODO

  • Abort started/running processes.
  • Browser history

Included 3:rd party libraries

SplitJs - Copyright (c) 2020 Nathan Cahill (MIT license)

click-web's People

Contributors

fredrik-corneliusson avatar jaybigguy10 avatar mareksimunek avatar whatang 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.