def index():
form=SQLFORM(db.post).process()
if form.accepted: redirect(URL('download',args=form.vars.file))
return dict(form=form)
def download(): return response.download() # already in scaffolding app!
On Friday, 14 February 2014 18:08:25 UTC-6, HittingSmoke wrote:
>
> I'm building my first public facing app with web2py using the basic image
> blog example from the docs but I'm concerned about performance.
>
> I'd like to have an upload form so I can post images to a blog with basic
> captions. I don't need any security for viewing so I'd like to have them
> served directly by the web server statically. Can I do this using web2py's
> built-in upload functionality? Right now my app is still very close to the
> example:
>
> db.py:
> db = DAL("sqlite://storage.sqlite")
>
> db.define_table('post',
> Field('title', unique=True),
> Field('file', 'upload'),
> Field('caption', 'text'),
> format = '%(title)s')
>
> db.define_table('comment',
> Field('post_id', 'reference post'),
> Field('author'),
> Field('email'),
> Field('body', 'text'))
>
> db.post.title.requires = IS_NOT_IN_DB(db, db.post.title)
> db.comment.post_id.requires = IS_IN_DB(db, db.post.id, '%(title)s')
> db.comment.author.requires = IS_NOT_EMPTY()
> db.comment.email.requires = IS_EMAIL()
> db.comment.body.requires = IS_NOT_EMPTY()
>
> db.comment.post_id.writable = db.comment.post_id.readable = False
>
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.