fredrik-corneliusson / click-web Goto Github PK
View Code? Open in Web Editor NEWServe click scripts over the web
License: MIT License
Serve click scripts over the web
License: MIT License
I have just been able to get back to my computer to test this and it seems that setting the input type doesn't give a email html box, I have this line for my email option, how do I get the html email box?
@click.option("--email", type=email, help='Input your email here')
Could be cool to implement password inputs, like here.
I'm going to see if I can figure it out looking at the click_inputs file
For text input, click-web now generates only a single-line input. Create a custom click type that is rendered as a textarea to facilitate easier viewing and editing.
as seen here EMAIL_TYPE = EmailParamType()
needs to be executed in the users program as this is what allows the user to select EMAIL_TYPE as an input type
this is because web_click_types is only being imported by input_feilds
some part of the click web program needs to set this variable
The url to post to is absolute to the flask server. If there is a reverse proxy before flask-server this will not work.
The url should just be the url.path instead.
Now applications are served directly under root url "/" and setting app.config['APPLICATION_ROOT'] is not supported.
Add support for configuring the application root for the generated click-web application.
In web the exit status of the command is communicated.
Add a json object with information on exit status to last line in the rawoutput response text.
Examples:
for OK:
{"result": "OK", "returncode": 0, "message": "Done"}
for ERROR:
{"result": "ERROR", "returncode": 2, "message": "Script exited with error code: 2"}
Hey!
I just found this project and really like the idea. Now I already had a tool written in typer and not click.
However typer is based on click so it is possible to use this tool with typer!
It would be nice to update the README and inform users that they can use typer with this tool and maybe add an example in the repo. The get_command function from typer generates a click command group and the only requirement to make it work with click-web is to set the name variable.
Take your Typer() instance and do the following
commands.py
import typer
typer_app = typer.Typer()
main.py
from click_web import create_click_web_app
import commands
import typer
typer_app = typer.Typer()
cmd = typer.main.get_command(commands.typer_app)
cmd.name = "cli"
app = create_click_web_app(commands, cmd)
start.sh
export FLASK_ENV=development
export FLASK_APP=app.py
flask run
Now running scripts depends on sys.executable beeing the same python interpreter (and venv) as flask is running as.
This does not work when running behind uwsgi as sys.executable points to uwsgi binary.
Fallback to use the python interpreter in the venv that uwsgi is configured with.
In some cases it is useful to call the server endpoints via simple scripts or curl without a web ui.
The current HTML form post API not suitable for this.
So implement a simple way to run the command as raw text in a form post.
Example
curl --request POST --url http://127.0.0.1:5000/_rawcmd --header 'Content-Type: text/plain' --data 'print-lines 5 --delay 1 --message Red'
The API is then very similar to how the click command would have been run on command line.
Note: In order for this to work some more advanced features will not be supported such as file upload/download.
I got this following error when trying to run example_command, anyone have any idea?
File "/home/andrew/.virtualenvs/example/lib/python3.5/site-packages/click_web/__init__.py", line 59
_flask_app.logger.info(f'OUTPUT_FOLDER: {OUTPUT_FOLDER}')
^
SyntaxError: invalid syntax
Hello,
Thank you for this repo. In this issue it is mentioned that "Providing a text input [to click-web] would not work unless you are on the same machine and it would be a dangerous vulnerability if you can make scripts process any folder on the server from the web." Is there a recommended way to safely allow the uploading and processing of files such as images using click-web?
Thanks.
The file picker (at least on Firefox/Ubuntu 18.08) doesn't allow choosing a directory, which is probably due to there not being a web API for it. A workaround might be to show a text input as a fallback which is not ideal but I don't know that there's really a good solution here due to the limitations of the web platform.
Hello,
Would you have any advice for someone trying to adapt the click-web functionality so that they could add the command routes to a website and not create an entirely new server for it?
I am trying to add it to a flask app that also has a cli where I would like to allow users to execute cli commands from the web interface, just like this project :).
I'm trying to read through the code, but would you have any pointers or tips?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.