flask

Am diving into web development using python. Will Flask be a good place to start!

Hi so as the title suggests, am just diving into web development. And if you might see my last post, it was about understanding the concept of sessions. So that is the level of my expertise in there. I went across a couple of frameworks, and I seriously dont have the patience of going through the entire django docs. So I stumbled across...

Flask/Werkzeug how to attach HTTP content-length header to file download

Hi, I am using Flask (based on Werkzeug) which uses Python. So the user can download a file, I'm using the send_from_directory function: http://flask.pocoo.org/docs/api/?highlight=send_from_directory#flask.send_from_directory However when actually downloading the file, the HTTP header content-length is not set. So the user has no idea...

with statement-Python

Hi , I am trying to understand the with statement in python.Everywhere I look it talks of opening and closing a file, and is meant to replace the try , finally block. Could someone post some other examples too.I am just trying out flask and there are with statements galore in it.Definitely request someone to provide some clarity on it ...

Flask - how do I combine Flask-WTF and Flask-SQLAlchemy to edit db models?

I'm trying to create an edit page for an existing model (already saved to db). The form object expects a multidict instance to populate its fields. This is what I have: # the model - assumes Flask-SQLAlchemy from flaskext.sqlalchemy import SQLAlchemy db = SQLAlchemyd(app) class Person(db.Model): id = db.Column(db.Integer, primary...

Not getting values from Select Fields with jQuery

I'm trying to implement some basic ajax functionality in website I'm creating. I'm using the Flask microframework and jQuery to do this. I have a lot of experience with python, what Flask is written in, but very little with javascript. This would be why I decided to use jQuery. ;) There is a nice example included with the Flask documen...

storing sessions on server.. why?

Hi I have been using Flask for some time now and I am really enjoying the framework. One thing that I fail to understand is that in almost all other places they talk about storing the session on the server and the session id on the client, which would then identify the session.However after using flask , I dont feel the need to do so. Sa...

How do I return a list as a variable in Python and use in Jinja2?

I am a very young programmer and I am trying to do something in Python but I'm stuck. I have a list of users in Couchdb (using python couchdb library & Flask framework) who have a username (which is the _id) and email. I want to use the list of email addresses in a select box in a jinja2 template. My first problem is how to access the e...

Storing images in google datastore using Flask (Python)

Hi all, I am using flask on google app engine and am desperately looking for help to solve this. The GAE documentation talks of storing images in the datastore using the BlobProperty , which should be done something like this:- class MyPics(db.Model): name=db.StringProperty() pic=db.BlobProperty() Now the image should be ...

Problems with python-oauth2 and Yahoo's Fantasy Sports API

I'm trying to build a web app that grabs fantasy sports info from Yahoo's API. I know that it requires the use of OAuth in order to speak to the API. It's being created using Flask and will run on Google App Engine. I've been trying to use python-oauth2 from the folks at SimpleGeo and I keep getting the same exact error when trying to...

Pull data from one couchdb doc via ids in another (Python)

I have two databases in CouchDB - DB1's documents are user data - name, email address, username, password but within one field that I store a list of the ID's saved in DB2 where user projects are saved (containing a username field and some Textfields. Example DB1 Document (Users) { "_id": "bobsmith1000", "_rev": "83-1...

WTforms validation

Hi I have a form class which looks like below:- class UserCreateForm(wtf.Form): name=wtf.TextField('Name',validators=[validators.Required(),username_check]) email=wtf.TextField('Email') userimage=wtf.FileField(u'Upload Image',validators=[checkfile]) The custom validator function " checkfile" looks like this:- def checkfi...