[web2py] configuring an app on pythonanywhere
After doing all the procedures for a new app e.g. www.myapp.com, completing registration on godaddy.com, upgrading on pythonanywhere etc. The app in web2py is also 'myapp'(same as domain name) I went to the web2py folder and changed/ added in the routes.py this: routers = dict( BASE = dict(default_application='rivelar'), rivelar = dict(languages=['en', 'it', 'jp'], default_language='en'), ) I reloaded the app through the web tab...etc but when trying to open the app as usual www.myapp.com, I get www.myapp.com/welcome/default/index. where is this line stored: 'welcome/default/index' How can I change or remove it to get www.myapp.com/myapp/default/index or simply www.myapp.com/index Regards -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/4f29c7ef-5128-4447-9cb8-33887089d8e5%40googlegroups.com.
[web2py] Re: Question with saving the thumbnail name on linux disk
Hi Dave and Everyone, I followed your advice -- Thanks for the code cleanup - However the issues still exist *ISSUE*#1 - The photo is still being saved in [E:\web2py_src\web2py\applications\*artpicstatic*\user_uploads] Correct path where it should be saved is [infile: E:\web2py_src\web2py\applications\artpic\static\user_uploads\] I simply do not understand why the application is saving the file in above path and not in the correct path in green. We have removed the problem causing code [foto_path = (request.folder + "static/user_uploads/" + upload_pic) ] from this method so where is it pulling it from and saving the files to this location only. Where is this magic happening from? Is it web2py *ISSUE*#2 - As the application cannot find the file in the correct path mentioned above it fails to create a thumbnail for it UPDATED CODE listing form = SOLIDFORM(db.fotoz , fields=fields, submit_button='Upload Foto') #if form.accepts(request.vars, session): if form.process().accepted: upload_pic = form.vars.upload_photo recordsID= form.vars.id #Thumbnail code print ("") infile = os.path.join(request.folder, "static", "user_uploads", upload_pic) print "infile: " , infile thumbnail_filename = "%s.thumbnail.jpg" % recordsID print "thumbnail_filename: ", thumbnail_filename thumbpath = outfile = os.path.join(request.folder, "static", "thumbs" , thumbnail_filename) print "thumbpath and outfile: ", outfile #Insert thumbnail and thumbnail path in db imgthumb field. db(db.fotoz.id==recordsID).update(imgthumb=thumbnail_filename, imgthumbpath=thumbpath) ##outfile if infile != outfile: try: im = Image.open(infile) im.thumbnail(size) #Check for image format image_format = (im.format) #print ("Image format: ", image_format) ### Watermark stuff == ## Watermark Text -- width, height = im.size draw = ImageDraw.Draw(im) watermark_text = "WATER" watermark_font = ImageFont.truetype('arial.ttf', 20) textwidth, textheight = draw.textsize(watermark_text, watermark_font) # calculate the x,y coordinates of the text margin = 5 x = width - textwidth - margin y = height - textheight - margin # draw watermark in the bottom right corner ## Specify this to fill font with red color , fill=(128,0,0,128)) OR #, fill=shadowcolor) OR fill="red" or fill="#ff" -- work draw.text((x, y), watermark_text, font=watermark_font, opacity=0.25) ## --- Watermark text ends --- #Process various image formats for making thumbnails. Currently supporting JPG/JPEG, GIF and PNG if (image_format == "JPEG"): im.save(outfile, "JPEG") if (image_format == "JPG"): im.save(outfile, "JPG") if (image_format == "GIF"): im.save(outfile, "GIF") if (image_format == "PNG"): im.save(outfile, "PNG") except IOError: print "Cannot create thumbnail (un-recognized format) for: " , infile #pass response.flash='Photo uploaded' *OUTPUT *- Path output for above code --* NOTE The infile must be saved in the path mentioned below but it does not exist there. * infile: E:\web2py_src\web2py\applications\artpic\static\user_uploads\fotoz.upload_photo.bf976468faa81f30.3030372e4a5047.JPG thumbnail_filename: 99.thumbnail.jpg thumbpath and outfile: E:\web2py_src\web2py\applications\artpic\static\thumbs\99.thumbnail.jpg Cannot create thumbnail (un-recognized format) for: E:\web2py_src\web2py\applications\artpic\static\user_uploads\fotoz.upload_photo.bf976468faa81f30.3030372e4a5047.JPG Regards, Rahul On Friday, August 30, 2019 at 1:42:44 AM UTC+5:30, Dave S wrote: > > > > On Thursday, August 29, 2019 at 12:21:41 PM UTC-7, Rahul wrote: >> >> Hi Val and Dave, >> >> Have a look at the code below - the line foto_path=... below works but it >> uploads the photos to"web2py\applications\artpicstatic\user_uploads" >> folder instead of web2py\applications\artpic\static\user_uploads folder. It >> also generates the thumbnail file. Now if I use *foto_path = >> os.path.join(request.folder + "static/user_uploads/" + upload_pic)* it >> shows the right path after normalization but does not upload the photo at >> all. And
[web2py] Re: Question with saving the thumbnail name on linux disk
On Friday, August 30, 2019 at 11:42:37 AM UTC-7, Rahul wrote: > > > Hi Dave and Everyone, > I followed your advice -- Thanks for the code cleanup - However > the issues still exist > > *ISSUE*#1 - The photo is still being saved in > [E:\web2py_src\web2py\applications\*artpicstatic*\user_uploads] > Correct path where it should be saved is [infile: > E:\web2py_src\web2py\applications\artpic\static\user_uploads\] > I simply do not understand why the application is saving the file in above > path and not in the correct path in green. We have removed the problem > causing code [foto_path = (request.folder + "static/user_uploads/" + > upload_pic) ] from this method so where is it pulling it from and saving > the files to this location only. Where is this magic happening from? Is it > web2py > I think it is time to see the declaration of db.fotoz. /dps > *ISSUE*#2 - As the application cannot find the file in the correct path > mentioned above it fails to create a thumbnail for it > > > > UPDATED CODE listing > > > form = SOLIDFORM(db.fotoz , fields=fields, submit_button='Upload Foto') > > #if form.accepts(request.vars, session): > if form.process().accepted: > upload_pic = form.vars.upload_photo > recordsID= form.vars.id > #Thumbnail code > print ("") > infile = os.path.join(request.folder, "static", "user_uploads", > upload_pic) > print "infile: " , infile > > thumbnail_filename = "%s.thumbnail.jpg" % recordsID > print "thumbnail_filename: ", thumbnail_filename > > thumbpath = outfile = os.path.join(request.folder, "static", > "thumbs" , thumbnail_filename) > print "thumbpath and outfile: ", outfile > > #Insert thumbnail and thumbnail path in db imgthumb field. > db(db.fotoz.id==recordsID).update(imgthumb=thumbnail_filename, > imgthumbpath=thumbpath) ##outfile > if infile != outfile: > try: > > im = Image.open(infile) > im.thumbnail(size) > #Check for image format > image_format = (im.format) > #print ("Image format: ", image_format) > > > ### Watermark stuff > == > > ## Watermark Text -- > width, height = im.size > draw = ImageDraw.Draw(im) > > > watermark_text = "WATER" > watermark_font = ImageFont.truetype('arial.ttf', 20) > textwidth, textheight = draw.textsize(watermark_text, > watermark_font) > # calculate the x,y coordinates of the text > margin = 5 > x = width - textwidth - margin > y = height - textheight - margin > > # draw watermark in the bottom right corner > ## Specify this to fill font with red color , > fill=(128,0,0,128)) OR #, fill=shadowcolor) OR fill="red" or > fill="#ff" -- work > draw.text((x, y), watermark_text, font=watermark_font, > opacity=0.25) > > ## --- Watermark text ends --- > > #Process various image formats for making thumbnails. > Currently supporting JPG/JPEG, GIF and PNG > if (image_format == "JPEG"): > im.save(outfile, "JPEG") > if (image_format == "JPG"): > im.save(outfile, "JPG") > if (image_format == "GIF"): > im.save(outfile, "GIF") > if (image_format == "PNG"): > im.save(outfile, "PNG") > except IOError: > print "Cannot create thumbnail (un-recognized format) > for: ", infile > #pass > > response.flash='Photo uploaded' > > > > > *OUTPUT *- Path output for above code --* NOTE The infile must be saved > in the path mentioned below but it does not exist there. * > > infile: > E:\web2py_src\web2py\applications\artpic\static\user_uploads\fotoz.upload_photo.bf976468faa81f30.3030372e4a5047.JPG > thumbnail_filename: 99.thumbnail.jpg > thumbpath and outfile: > E:\web2py_src\web2py\applications\artpic\static\thumbs\99.thumbnail.jpg > Cannot create thumbnail (un-recognized format) for: > E:\web2py_src\web2py\applications\artpic\static\user_uploads\fotoz.upload_photo.bf976468faa81f30.3030372e4a5047.JPG > > Regards, > > Rahul > > > > > > On Friday, August 30, 2019 at 1:42:44 AM UTC+5:30, Dave S wrote: >> >> >> >> On Thursday, August 29, 2019 at 12:21:41 PM UTC-7, Rahul wrote: >>> >>> Hi Val and Dave, >>> >>> Have a look at the code below - the line foto_path=... below works but >>> it uploads the photos to