background preloader

Tutorials

Facebook Twitter

Flask-RestFul

Designing a RESTful API with Python and Flask. In recent years REST (REpresentational State Transfer) has emerged as the standard architectural design for web services and web APIs.

Designing a RESTful API with Python and Flask

In this article I'm going to show you how easy it is to create a RESTful web service using Python and the Flask microframework. What is REST? The characteristics of a REST system are defined by six design rules: Client-Server: There should be a separation between the server that offers a service, and the client that consumes it.Stateless: Each request from a client must contain all the information required by the server to carry out the request. What is a RESTful web service? The REST architecture was originally designed to fit the HTTP protocol that the world wide web uses. Central to the concept of RESTful web services is the notion of resources.

Saturday morning hack: a little note-taking app with Flask. A couple Saturdays ago I spent the morning hacking together a note-taking app.

Saturday morning hack: a little note-taking app with Flask

I'm really pleased with the result, so I thought I'd share the code in case anyone else might find it useful. The note-taking project idea came about out of necessity -- I wanted something that worked well from my phone. While I have a personal wiki site I've used for things like software installation notes or salsa recipes, I've also noticed that because it's so cumbersome to use from my phone, I often end up emailing things to myself.

Plus a wiki implies a kind of permanence to the content, making it not a great fit for these impromptu notes. I also like to use markdown to format notes, but markdown isn't too easy on a phone because of the special characters or the need to indent blocks of text. Here is how the app appears on a narrow screen like my phone: And here it is on my laptop: If you'd just like to see the code, here is the multi-file gist. Feature review The tools Setting it up. How To Structure Large Flask Applications. Introduction There are many methods and conventions for structuring Python web applications.

How To Structure Large Flask Applications

Although certain frameworks are shipped with tools (for scaffolding) to automate -- and ease -- the task (and the headaches), almost all solutions rely on packaging / modularizing applications as the codebase gets distributed [logically] across related files and folders. The minimalist web application development framework Flask, has its own - blueprints. In this DigitalOcean article, we are going to see how to create an application directory, and structure it to work with re-usable components created with Flask's blueprints.

These pieces allow (and simplify) the maintenance and the development of application components greatly. Glossary 1. 2. 3. Prepare The Operating SystemSetting up Python, pip and virtualenv. 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. Structuring flask apps, a how-to for those coming from Django. The other day a friend of mine was trying out flask-peewee and he had some questions about the best way to structure his app to avoid triggering circular imports.

Structuring flask apps, a how-to for those coming from Django

For someone new to flask, this can be a bit of a puzzler, especially if you're coming from django which automatically imports your modules. Large app how to · mitsuhiko/flask Wiki. This document is an attempt to describe the first step of a large project structure with flask and some basic modules: SQLAlchemyWTForms Please feel free to fix and add your own tips.

Large app how to · mitsuhiko/flask Wiki

Installation Flask Flask Installation I recommend using virtualenv: it is easy and allows multiple environments on the same machine and doesn't even require you to have super user rights on the machine (as the libs are locally installed). Flask-SQLAlchemy SQLAlchemy provides an easy and advanced way to serialize your object to different types of relational databases. Building websites in Python with Flask.

For some times now, I have been doing some projects in Python and some were web applications.

Building websites in Python with Flask

Flask is a small framework to do exactly that and I have found it perfect for the job. It’s really easy to use, fast, has good documentation and a good community. Tech & statup blog by maximebf. My last post about creating websites with Flask covered the steps to create a simple application.

Tech & statup blog by maximebf

What happens when it grows bigger? In this post I will take as example a common use case for a web app: a public section (homepage, tour, signup, login) a member only section (the app, user settings) an api Each member will have its own subdomain (ie: if my username is maximebf, I get the maximebf.example.com subdomain).

This app will need input validation and background processing (eg: resizing the user’s profile picture). I’ll assume the same file organization as I described in my previous post. Getting modular with Blueprints Flask provides a feature called Blueprints which let your organize your app as modules. I like to create a modules folder in my application directory where all my module files will be stored. Example/ modules/ __init__.py public.py member.py api.py.