Re: A library that converts a type-annotated function into a webpage with HTML forms?

2020-10-01 Thread Dieter Maurer
James Lu wrote at 2020-9-30 16:45 -0400:
>Is there a python library available that converts a type-annotated Python
>function into a webpage with HTML forms?
>
>Something like:
>
>
>def foo(name: str, times: int):
>return f"Hello {name}!" * times
>
>serve_from(foo, host="0.0.0.0", port=3000)
>
>Turning into a server that serves something like this:
>
>
>name
>
>
>
>
>And hitting the submit button executes the function.

You could have a look at "pydoc" ("the Python documentation tool").

As the name indicates, it is for documentation not for the
execution of funtions (which may be **VERY** dangerous).
But it can show you how to integrate an HTTP server
and how to use Python's `inpect` module to determine
function signatures.
You would need to create the forms yourself and the function
execution actions (and again: executing arbitrary functions is
really dangerous -- do not do it!).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A library that converts a type-annotated function into a webpage with HTML forms?

2020-09-30 Thread Kushal Kumaran
On Wed, Sep 30 2020 at 04:45:47 PM, James Lu  wrote:
> Is there a python library available that converts a type-annotated Python
> function into a webpage with HTML forms?
>
> Something like:
>
>
> def foo(name: str, times: int):
> return f"Hello {name}!" * times
>
> serve_from(foo, host="0.0.0.0", port=3000)
>
> Turning into a server that serves something like this:
>
> 
> name
> 
> 
> 
>
> And hitting the submit button executes the function.
>
> I'm aware I could use sls, and build a form manually, but that's extra work.

https://fastapi.tiangolo.com/

https://fastapi.tiangolo.com/tutorial/path-params/#documentation

Depending on what you need to use the forms for, this might suffice.

-- 
regards,
kushal
-- 
https://mail.python.org/mailman/listinfo/python-list


A library that converts a type-annotated function into a webpage with HTML forms?

2020-09-30 Thread James Lu
Is there a python library available that converts a type-annotated Python
function into a webpage with HTML forms?

Something like:


def foo(name: str, times: int):
return f"Hello {name}!" * times

serve_from(foo, host="0.0.0.0", port=3000)

Turning into a server that serves something like this:


name




And hitting the submit button executes the function.

I'm aware I could use sls, and build a form manually, but that's extra work.
-- 
https://mail.python.org/mailman/listinfo/python-list