flask

Python Framework for small website

I am planning a small, simple website to showcase myself as an engineer. My preferred language is Python and I hope to use it to create my website. My pages will be mostly static, with some database stored posts/links. The site will be simple, but I would like to have freedom in how it operates. I plan on using CSS/JS for the design, so...

Django vs Flask for a long-term project

I am looking for a comparison of django and flask for a project that will live for a long time, and will need to be maintained, built upon and grow as the months progress. I am considering Flask + SQLAlchemy or django. I do not need batteries, as I usually end up having to modify them, so it is fine if I have to re-implement a couple o...

mod_wsgi unexpected behavior on bookmarklet submit or related database action

[updated below] I have a bit of a problem deploying a site on apache with mod_wsgi with some javascript bookmarklet functionality; alpha site is up and usable here: stemhub.org. The problem is that the bookmarklet (which is a browser menu button) submits to a page like http://stemhub.org/submit/http://the-users-link.com/here which th...

MongoDB - will it fit a small hobby web application?

I'm working on a small web application using the Python Flask framework. For a few happy weeks SQLAlchemy was a perfect fit for my needs. In the meantime I found out more about MongoDB, played with it locally and started thinking of using it instead of MySql along with SQLAlchemy. Is this a good idea in terms of: Suitability. The pro...

Passing html to template

I'm building an admin for Flask and SQLAlchemy, and I want to pass the html for the different inputs to my view using render_template. The templating framework seems to escape the html automatically, so all <"'> are converted to html entities. How can I disable that so that the html renders correctly? ...

How deploy Flask application on Webfaction?

Anybody know how to deploy a simple Flask application on Webfaction? I know Webfaction support mod_wsgi and I read the guide on the Flask site but still I can't make my app working. Anybody have a working configuration? UPDATE to answer a comment by Graham Dumpleton. I get a 500 Internal server error. Apache does not show any error in ...

Multilingual flask application

Is there a preferred way to make a Flask application multilingual? Ideally, the solution would enable to @app.route the same view to use different urls for each languages, like @app.route(en='/staff/', fr='/equipe/). I'm pretty confident I could hack something like that together, but an existing library would sure save me some time. Than...

Sqlite. How to get value of Auto Increment Primary Key after Insert, other than last_insert_rowid() ?

I am using Sqlite3 with Flask microframework, but this question concerns only the Sqlite side of things.. Here is a snippet of the code: g.db.execute('INSERT INTO downloads (name, owner, mimetype) VALUES (?, ?, ?)', [name, owner, mimetype]) file_entry = query_db('SELECT last_insert_rowid()') g.db.commit() The downloads table has anot...

Flask / Python. Get mimetype from uploaded file.

Hi, I am using Flask micro-framework 0.6 and Python 2.6 I need to get the mimetype from an uploaded file so I can store it. Here is the relevent Python/Flask code: @app.route('/upload_file', methods=['GET', 'POST']) def upload_file(): if request.method == 'POST': file = request.files['file'] mimetype = #FIXME ...

Python beginner question - trying to understand return statement

Basically I want to return the contents of create_user in the register function to use to save to my database. I am a complete beginner. What am I misunderstanding? def register(): form = SignupForm(request.form) if request.method == 'POST' and form.validate(): create_user = ({'username' : form.username.data, 'email' : form....

Using Python, getting the name of files in a zip archive

Hi, I have several very large zip files available to download on a website. I am using Flask microframework (based on Werkzeug) which uses Python. Is there a way to show the contents of a zip file (i.e. file and folder names) - to someone on a webpage - without actually downloading it? As in doing the working out server side. Assume t...

Is there anything wrong with creating a Python Pickle powered website?

I have been toying with this idea for quite awhile now, but haven't seen any information on people doing it. I have a small website project where I need to load and modify 1 object. This object is pretty simple, and shouldn't be more than a few kb. Instead of running a DB for this small amount of data, why not just use pickle and/or shel...

Flask error: werkzeug.routing.BuildError

I modify the login of flaskr sample app, the first line get error. But www.html is in the template dir. return redirect(url_for('www')) #return redirect(url_for('show_entries')) display error: werkzeug.routing.BuildError BuildError: ('www', {}, None) Thanks for help! ...

Flask/Werkzeug, how to return previous page after login

Hi, I am using the Flask micro-framework which is based on Werkzeug, which uses Python. Before each restricted page there is a decorator to ensure the user is logged in, currently returning them to the login page if they are not logged in, like so: # Decorator def logged_in(f): @wraps(f) def decorated_function(*args, **kwargs)...

How to solve import errors while trying to deploy Flask using WSGI on Apache2

I am having an issue deploying a flask app on apache2 using wsgi. I have posted the error logs and config files below. I have tried moving things around, renaming them, etc, but all give me an internal server error. Not sure why I'm getting the import error. Any input / suggestions are appreciated, thanks! Here is my apache error.log [...

How to test the login func in flask?

I write this according to flaskr sample, I can login with browser,but test fails. Thanks for your help! @app.route('/login', methods=['GET', 'POST']) def login(): error = None if request.method == 'POST': username = request.form['username'] password = request.form['password'] if lib.authenticate_u...

Flask for Python - architectural question regarding the system.

I've been using Django and Django passes in a request object to a view when it's run. It looks like (from first glance) in Flask the application owns the request and it's imported (as if it was a static resource). I don't understand this and I'm just trying to wrap my brain around WSGI and Flask, etc. Any help is appreciated. ...

Get ip address of visitors using Python (specifically Flask micro-framework)

Hi, I am using the Flask micro-framework (based on Werkzeug) which uses Python (2.6 in my case). I'm making a website where users can log on and download files. I need to get the ip address of users when they log on (for logging purposes). Does anyone know how to do this? Surely there is a way to do it with Python? I apologize for t...

Redirecting an old URL to a new one with Flask micro-framework

Hi, I'm making a new website to replace a current one, using Flask micro-framework (based on Werkzeug) which uses Python (2.6 in my case). The core functionality and many pages are the same. However by using Flask many of the previous URLs are different to the old ones. I need a way to somehow store the each of the old URLs and the ne...

How to understand this code of flask?

Could anyone explain this line? g = LocalProxy(lambda: _request_ctx_stack.top.g) code from flask from werkzeug import LocalStack, LocalProxy # context locals _request_ctx_stack = LocalStack() current_app = LocalProxy(lambda: _request_ctx_stack.top.app) request = LocalProxy(lambda: _request_ctx_stack.top.request) session = LocalProx...