I wrote out a file in my app, no error reported, but where is my file?
Not sure, but you can read / write to
/tmp
so in your example swap out “order.txt” for “/tmp/order.txt”
I do it quite a lot, but bear in mind that any data written is not guaranteed to still be there after the server call terminates. It might still be there, but no promises.
you mean in my local laptop /tmp?
No.
Anvil gives you access to your own ring fenced /tmp on their servers.
Here’s a thread discussing it :
could you please show me where is my own ring fenced /tmp with picture?
You just use it.
So instead of :
file = open('order.txt','w')
you write :
file = open('/tmp/order.txt','w')
Nothing to show really.
It’s possible that if you omit the “/tmp” that it writes there anyway. You could test that by trying to open it again and read it.
Interesting, it works. But we don’t know where it is. Is there anyway to enlarge the frame of alert? to make it looks neat a bit
If you mean the file, it’s on the Anvil server in an isolated virtual “/tmp” directory. Exactly where it is is not really important.
You could create a form containing a textarea control, and use that form as the content area of the alert box. For example :
from myAlertForm import myAlertForm
...
f = myAlertForm()
f.text_area.text = myfileoutput
alert(f)
which assumes you have a textarea control (called “text_area”) on a form called myAlertForm. Now at least you can scroll down the textarea.
You could also make the form capable of parsing the text into a data grid for example. So you could create an array of dicts and pass that to the items property of a datagrid or repeating panel.
If you’re going to be displaying a lot of data in a pop up form in an alert window, set the “large” property to True to let it take up more space on the screen ( Anvil | Reference)