Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Python Boilerplate in Flask.

NotificationsYou must be signed in to change notification settings

Mindinventory/flask-boilerplate-structure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



Speed up building your scalable application with this boilerplate which includes the latest python support, and a lot more features like Admin panel,SMTP configuration, LRF flow(Login and Registration), mail authentication, separate settings file for root project configuration, travis integration(CI), alembic (database migrations tool), faker(fake data generator), ORM support(SQLAlchemy), Jinja2 (Template Engine) and it is flexible enough for adding and using other libraries.

Table of content

Standard

-If using standard instructions, Python ≥ 3.6 is required.
-A virtual environment is recommended (like virtualenv==20.4.3).
-pip is required for installing software packages.
-It could be easily adapted to run on MySQL or SQLite, but the default installation instructions below assume the use of PostgreSQL.

Project Structure

FlaskBoilerPlate   ├── app/   │    ├── api/   │    │    ├── v1/   │    │    │    ├── __init__.py   │    │    │    ├── routes.py    │    │    │    └── views.py        │    │    └──  __init__.py   │    ├── auth/      │    │    ├── __init__.py   │    │    ├── forms.py   │    │    ├── models.py   │    │    ├── routes.py   │    │    └── views.py   │    ├── static/   │    │    ├── css/   │    │    ├── img/   │    │    └── js/   │    ├── templates/   │    │    ├── email/   │    │    ├── errors/   │    │    ├── forms/    │    │    ├── layouts/   │    │    └── pages/    │    ├── toolbox/   │    │    ├── __init__.py    │    │    ├── admin.py   │    │    └── email.py      │    ├── __init__.py   │    └── seeding.py   ├── env/   ├── migrations/   ├── config.py   ├── requirements.txt   ├── run.py   ├── WSGI.py   └── README.md

Project Directories

1 . app

Main project directory where all app are created.This contains following files and folder.

  • api

  Contains all api versioning and routes files with signup and login apis.

  • auth

  Contains basic authentication features like signup, login, forgot password and reset password views.

  • static

  Contains the Css, Img and Js files used in your project.

  • templates

  Contains the HTML templates used in your project.

  • toolbox

  Contain files for flask admin and sending emails.

  • init.py

  Main app are register here.

  • seeding.py

  Seeding file for create fake user.

2 . env

Contains environment variables.

3 . migrations

Generates automatically when run database migrations command.

4 . config.py

Contains whole projects configurations.

5 . requirements.txt

File contains all project dependency.

6 . run.py

To run your application.

Features

  • User account sign up, login, password reset, all through asynchronous email confirmation.
  • Flask-WTForms for Form generation
  • Flask-SQLAlchemy with basic User model
  • Easy database migrations with Flask-Migrate
  • Flask-Admin for administrative task
  • PyJWT for JWT token authentication
  • Flask-RESTful for Api versioning
  • Bootstrap 4 for starter templates
  • itsdangerous for generating random tokens for the confirmation emails.
  • Faker used for generating fake user for database

Quick Start

  1. Initialize and activate a virtualenv:
    • for windows
    virtualenv env\path\to\env\Scripts\activate
    • for linux
    sudo apt install python3-venvpython3 -m venv envsource env/bin/activate
  2. Install the dependencies:
    pip install -r requirements.txt# for windowspip3 install -r requirements.txt# for linux
  3. For database configuration in config.py
    POSTGRES = {'user':'postgres','pw':'password','db':'my_database','host':'localhost','port':'5432',}SQLALCHEMY_DATABASE_URI = 'postgresql://%(user)s:\%(pw)s@%(host)s:%(port)s/%(db)s' % POSTGRES
  4. Run command for database migration:
    flask db initflask db migrate -m "Initial migration."flask db upgrade
  5. Run the development server:
    • for windows
    set FLASK_APP=run.pyset FLASK_ENV=developmentflask run
    • for linux
    export FLASK_APP=run.pyexport FLASK_ENV=developmentflask run
  6. Navigate tohttp://localhost:5000

  7. Generate fake user:
    flask seeder --count=n# here n is number of user
  8. SMTP configuration:

On successful running of the project

home.gif


[8]ページ先頭

©2009-2025 Movatter.jp