background preloader

Python Flask Web Mapping

Facebook Twitter

Introduction to PostGIS: Part 1 - Tutorial. PostGIS is a promising extension for the PostgreSQL database that adds spatial objects to a database.

Introduction to PostGIS: Part 1 - Tutorial

In simple words, PostGIS adds geographical capabilities to a database. With the growing importance of Location Based Systems (LBS) in our day-to-day life, PostGIS is a blessing in disguise to developers and architects building geo-aware applications. PostGIS removes the trial-and-error based method of location based content storage, retrieval and search, by providing a concise and accurate back-end to perform such calculations. Developers with a MySQL background would know how difficult it is to build and scale a location based database in MySQL.

Although MySQL has some spatial extensions, they are far from offering the advantages and speed that PostGIS provides. With the recent release of PostGIS 2.1 – the power of PostGIS has tripled, from support for Raster and Vector analysis in the database to support for 3D geometries (latitude, longitude and height/altitude). Getting ready. The Flask Mega-Tutorial, Part I: Hello, World! This is the first article in a series where I will be documenting my experience writing web applications in Python using the Flask microframework.

The Flask Mega-Tutorial, Part I: Hello, World!

NOTE: This article was revised in September 2014 to be in sync with current versions of Python and Flask. Here is an index of all the articles in the series that have been published to date: My background I'm a software engineer with double digit years of experience developing complex applications in several languages. I first learned Python as part of an effort to create bindings for a C++ library at work.

In addition to Python, I've written web apps in PHP, Ruby, Smalltalk and believe it or not, also in C++. Flask Biography Tutorial. First News App — First News App documentation. How I Structure My Flask Applications. June 26, 2013 How I Structure My Flask Applications Flask has been my preferred web framework as of late.

How I Structure My Flask Applications

I think it has a great core feature set and Armin, the main author, has done well to keep it's API minimal and easy to digest even for developers that are relatively new to Python. However, given that it is a rather minimal framework, it can be often difficult to decide on how to structure an application after it reaches a certain level of complexity.

GeoAlchemy 2 Documentation — GeoAlchemy2 0.2.4 documentation. AJAX with jQuery — Flask Documentation (0.10) jQuery is a small JavaScript library commonly used to simplify working with the DOM and JavaScript in general.

AJAX with jQuery — Flask Documentation (0.10)

It is the perfect tool to make web applications more dynamic by exchanging JSON between server and client. JSON itself is a very lightweight transport format, very similar to how Python primitives (numbers, strings, dicts and lists) look like which is widely supported and very easy to parse. It became popular a few years ago and quickly replaced XML as transport format in web applications. Loading jQuery In order to use jQuery, you have to download it first and place it in the static folder of your application and then ensure it’s loaded.

Another method is using Google’s AJAX Libraries API to load jQuery: <script src="//"></script><script>window.jQuery || document.write('<script src="{{ url_for('static', filename='jquery.js') }}">\x3C/script>')</script> Where is My Site? Do you know where your application is? The HTML. Primer on Jinja Templating. Right out of the box, Flask includes the powerful Jinja templating language.

Primer on Jinja Templating

It’s modeled after Django templates (but it renders much faster) and, although, Flask does not force you to use any templating language, it assumes that you’ll be using Jinja since it does come pre-installed. For those who have not been exposed to a templating language before, such languages essentially contain variables as well as some programming logic, which when evaluated (or rendered into HTML) are replaced with actual values. The variables and/or logic are placed between tags or delimiters. For example, Jinja templates use {% ... %} for expressions or logic (like for loops), while {{ ... }} are used for outputting the results of an expression or a variable to the end user.

The latter tag, when rendered, is replaced with a value or values, and are seen by the end user. Use Flask-Login to Add User Authentication to your Python Application - OpenShift Blog. A step-by-step SQLAlchemy tutorial. About This Tutorial This tutorial is for SQLAlchemy version 0.2.

A step-by-step SQLAlchemy tutorial

You may notice that some sections are marked "New in 0.2". If this is the first time you're reading this tutorial, you can safely skip those sections. On the other hand, if you read the previous version of this tutorial and are now trying to learn SQLAlchemy 0.2, then just search for the text "New in 0.2" and you'll have a lot less reading to do this time around. (Do make sure to update all the demo code, though: every single file of the demo code has changed, and you'll get errors if you try to run the old demo code under SQLAlchemy 0.2). If you're using SQLAlchemy version 0.3, don't worry — everything you'll learn in this tutorial still works just fine under SQLAlchemy 0.3.

Now, on with the tutorial. Getting Started Before we install SQLAlchemy, let's make sure you have the latest version of setuptools, which can make your life a lot easier. Easy_install --help easy_install SQLAlchemy First Steps First Steps, in detail Joins.