Forums

can't save pil image

On local PC it is working, but on PythonAnywhere it don't save the image into static/obrazok.jpg Code is part of flask_app.py

Many thanks for any help or suggestion.

... def Chaos():

xf=1200  #definuje vysku a sirku obrazku
yf=800
pozadie="#"+''.join([random.choice('0123456789ABCDEF') for i in range(6)])

image1 = Image.new("RGB", (xf, yf), pozadie)
draw = ImageDraw.Draw(image1)



polomermax=10
polomer=polomermax
for i in range(30000):
   x=random.randrange(xf)
   y=random.randrange(yf)
   polomer=random.randrange(polomermax)
   shape = [(x, y), (x+polomer, y+polomer)]
   farba="#"+''.join([random.choice('0123456789ABCDEF') for j in range(6)])
   farba2="#"+''.join([random.choice('0123456789ABCDEF') for k in range(6)])
   draw.ellipse(shape, fill=farba, outline=farba2, width=1)



cesta =(r'static/obraz.jpg')
**image1.save(cesta)**  here it crashes

See https://help.pythonanywhere.com/pages/NoSuchFileOrDirectory/