项目作者: app-generator

项目描述 :
Boilerplate Code - Flask Template project | AppSeed
高级语言: JavaScript
项目地址: git://github.com/app-generator/boilerplate-code-flask.git
创建时间: 2020-01-26T11:12:08Z
项目社区:https://github.com/app-generator/boilerplate-code-flask

开源协议:Other

下载


Flask Boilerplate

Reference codebase used by AppSeed in all Flask Apps and Dashboard starters - the product uses an amazing design crafted by Creative-Tim.


🚀 Built with App Generator, Timestamp: 2022-06-08 12:24

  • Up-to-date dependencies
  • Database: SQLite, MySql
    • Silent fallback to SQLite
  • DB Tools: SQLAlchemy ORM, Flask-Migrate (schema migrations)
  • ✅ Session-Based authentication (via flask_login), Forms validation
  • ✅ Docker, Flask-Minify (page compression)
  • 🚀 Deployment


Material Kit - Starter generated by AppSeed.


Start with Docker

👉 Step 1 - Download the code from the GH repository (using GIT)

  1. $ git clone https://github.com/app-generator/boilerplate-code-flask.git
  2. $ cd boilerplate-code-flask


👉 Step 2 - Start the APP in Docker

  1. $ docker-compose up --build

Visit http://localhost:5085 in your browser. The app should be up & running.


Manual Build

Download the code

  1. $ git clone https://github.com/app-generator/boilerplate-code-flask.git
  2. $ cd boilerplate-code-flask


👉 Set Up for Unix, MacOS

Install modules via VENV

  1. $ virtualenv env
  2. $ source env/bin/activate
  3. $ pip3 install -r requirements.txt


Set Up Flask Environment

  1. $ export FLASK_APP=run.py
  2. $ export FLASK_ENV=development


Start the app

  1. $ flask run

At this point, the app runs at http://127.0.0.1:5000/.


👉 Set Up for Windows

Install modules via VENV (windows)

  1. $ virtualenv env
  2. $ .\env\Scripts\activate
  3. $ pip3 install -r requirements.txt


Set Up Flask Environment

  1. $ # CMD
  2. $ set FLASK_APP=run.py
  3. $ set FLASK_ENV=development
  4. $
  5. $ # Powershell
  6. $ $env:FLASK_APP = ".\run.py"
  7. $ $env:FLASK_ENV = "development"


Start the app

  1. $ flask run

At this point, the app runs at http://127.0.0.1:5000/.


👉 Create Users

By default, the app redirects guest users to authenticate. In order to access the private pages, follow this set up:

  • Start the app via flask run
  • Access the registration page and create a new user:
    • http://127.0.0.1:5000/register
  • Access the sign in page and authenticate
    • http://127.0.0.1:5000/login


Codebase Structure

The project is coded using blueprints, app factory pattern, dual configuration profile (development and production) and an intuitive structure presented bellow:

  1. < PROJECT ROOT >
  2. |
  3. |-- apps/
  4. | |
  5. | |-- home/ # A simple app that serve HTML files
  6. | | |-- routes.py # Define app routes
  7. | |
  8. | |-- authentication/ # Handles auth routes (login and register)
  9. | | |-- routes.py # Define authentication routes
  10. | | |-- models.py # Defines models
  11. | | |-- forms.py # Define auth forms (login and register)
  12. | |
  13. | |-- static/
  14. | | |-- <css, JS, images> # CSS files, Javascripts files
  15. | |
  16. | |-- templates/ # Templates used to render pages
  17. | | |-- includes/ # HTML chunks and components
  18. | | | |-- navigation.html # Top menu component
  19. | | | |-- sidebar.html # Sidebar component
  20. | | | |-- footer.html # App Footer
  21. | | | |-- scripts.html # Scripts common to all pages
  22. | | |
  23. | | |-- layouts/ # Master pages
  24. | | | |-- base-fullscreen.html # Used by Authentication pages
  25. | | | |-- base.html # Used by common pages
  26. | | |
  27. | | |-- accounts/ # Authentication pages
  28. | | | |-- login.html # Login page
  29. | | | |-- register.html # Register page
  30. | | |
  31. | | |-- home/ # UI Kit Pages
  32. | | |-- index.html # Index page
  33. | | |-- 404-page.html # 404 page
  34. | | |-- *.html # All other pages
  35. | |
  36. | config.py # Set up the app
  37. | __init__.py # Initialize the app
  38. |
  39. |-- requirements.txt # App Dependencies
  40. |
  41. |-- .env # Inject Configuration via Environment
  42. |-- run.py # Start the app - WSGI gateway
  43. |
  44. |-- ************************************************************************



Flask Boilerplate - Open-source starter generated by App Generator.