Coder Social home page Coder Social logo

flask-template-app's Introduction

Flask template app

Simple Flask app with Gunicorn and Docker.

Implements the basics I constantly keep re-inventing for Flask based apps:

  1. Package structure
  2. Developing with Flask builtin server while in Docker
  3. PostgreSQL and psycopg2 (ORM is not needed, mkey..)
  4. Blueprints
  5. Flask-Restful for API's
  6. Bootstrap base template and static files

Database

I don't really believe in ORMs, so plain old SQL it is. PostgreSQL is also a bit nicer to work with than MySQL, the only pain being getting psycopg2 installed to Alpine based docker image. Database root and application user credentials can be found in docker-compose.yml.

Build, install, run

docker build -t kerma/flask-template-app .
docker-compose up

You can skip build step if you have devpi-server running on localhost:3141. After Postgres has booted itself run (password: flask):

sh script/bootstrap.sh

Hello World can be now seen on http://localhost:8080.

For restful API you can use POST, PUT and GET methods on /rest/hello/ endpoint. For example using httpie:

$ http POST http://localhost:8080/rest/hello/ value=world
HTTP/1.0 200 OK
Content-Length: 16
Content-Type: application/json
Date: Fri, 14 Sep 2018 14:08:42 GMT
Server: Werkzeug/0.14.1 Python/3.7.0

{
    "id": 1
}


$ http http://localhost:8080/rest/hello/1
HTTP/1.0 200 OK
Content-Length: 38
Content-Type: application/json
Date: Fri, 14 Sep 2018 14:09:24 GMT
Server: Werkzeug/0.14.1 Python/3.7.0

{
    "id": 1,
    "value": "world"
}

flask-template-app's People

Contributors

kerma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.