Coder Social home page Coder Social logo

flask-quickstart's Introduction

flask-quickstart

v1.1.0

flask-quickstart is a minimal boilerplate/template for starting your new Flask project.

The good thing about flask-quickstart is that it does not assume that you are using any Flask extensions. It sets up your project layout, main Blueprint, configuration and then gets out of your way!

Quickstart to flask-quickstart

First clone the repostiory

$ git clone https://github.com/bittobennichan/flask-quickstart.git

Change directory to flask-quickstart

$ cd flask-quickstart

Create a virtual environment and install dependencies

$ python -m venv venv
$ source venv/bin/activate
$ python -m pip install --upgrade pip setuptools
$ python -m pip install -r requirements.txt

Start the development server

$ python manage.py runserver

That's it!

Navigate to http://127.0.0.1:5000/ and start your new project!

Project layout

flask-quickstart/
├── app/
│   ├── __init__.py
│   ├── main/
│   │   ├── forms.py
│   │   ├── __init__.py
│   │   └── views.py
│   ├── models/
│   ├── static/
│   │   ├── css/
│   │   ├── img/
│   │   └── js/
│   └── templates/
│       ├── common/
│       ├── error/
│       │   ├── 404.html
│       │   └── 500.html
│       └── main/
│           └── index.html
├── CHANGES
├── config.py
├── instance/
│   └── config.py
├── LICENSE
├── manage.py
├── README.md
├── requirements.txt
├── tests/
│   ├── __init__.py
│   └── test_main.py
└── wsgi.py

When you clone the repo, you'll notice that you will be missing the config.py file in instance folder. You will find an example_config.py file instead.

├── instance/
    └── example_config.py

This is b'coz it should be set to be ignored in the .gitignore file. Infact everything except example_config.py is set to be ignored. This is where you will store the deployment/production configuration values. You don't want to accidently push this to Github. Rename the file to config.py after you clone the repo.

If available, the values in flask-quickstart/instance/config.py will override any config values set in tthe environment form flask-quickstart/config.py when environment is set to production (it is set to development by default).

The wsgi.py file uses production as the environment. This file is to be used by WSGI servers such as Gunicorn.

You can also test production environment using manage.py

$ python manage.py runserver --env production

manage.py

As mentioned earlier, manage.py has just one command runserver which is used to run the Flask development server.

It takes two optional parameters

  • env - Environment to use while running server. Supports production, development and testing out of the box. Default is development.

  • port - Port to use while running server. Default is 5000.

Eg.

$ python manage.py runserver --env production --port 5566

Runs the server in production environment on port 5566.

You can extend manage.py to support additional commands, parameters etc.

Developing your application

flask-quickstart is built in such a way that you can easily integrate extensions, Blueprints, tests etc. The files are commented to help you out with this.

flask-quickstart's People

Contributors

bittobennichan avatar

Watchers

 avatar  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.