This is all you need to write an application that does post to GPT and returns the result in the textarea. No javascript needed! Only HTML and equal naming of field names. The prompt-id of the html element should match the field name server side.
Here's an example of an interactive calculator that calculates your expression after typing f. No javascript need and no polling. It' a textbox, but if you would change it to a textarea, it doesn't matter. As long if it has the right javascript events.
### Eval server side execution
```python
class EvalBox(Component):
async def on_change(self, value):
try:
if value and value.strip().endswith("="):
value = value.strip()[:-1]
try:
result = eval(value)
value = value + "= " + str(result)
await self.set_attr("value", value)
except:
pass
except AttributeError:
print(value)
return value
```
### HTML
```html
<inputid="eval_box"type="text"value="wiii"/>
```
## Random string stream from the Demo
This is the code of that random ascii banner.
```python
class RandomString(Component):
async def task_random(self):
import random
rand_bytes = [random.choice("abcdefghijklmnopqrstuvwxyz") for _ in range(15)]