Giter VIP home page Giter VIP logo

flask-bootstrap-anywhere's Introduction

Flask-Bootstrap-Anywhere

This is a skeleton application written in python using Flask microframework. It comes with support for user registration, login, session management, password recovery, password reset and database connection. These features are achieved by Flask-Security-Too, which in turn achieves them by various flask extensions such as Flask-Login, Flask-WTF etc. Front-end styling is done using Bootstrap.

Motivation

In general, many web applications require some level of user-management. While Django can be suitable for big projects, for relatively small projects it might be an overkill. Further, Flask offers more flexibility. However, with Flask being a "microframework", we have to choose from a variety of plugins to build a working system.

This application fits together a handful of such commonly used plugins for commonly required tasks, and aims to save developers' effort.

Features

Back-end

  • User Management
    • Registration
    • Login
    • Session Management
    • Password Recovery
    • Roles
  • Database Support
    • MySQL
    • SQLite
    • MongoDB (incomplete)
  • Mail
  • Migrations (Powered by Flask-Migrate)
  • Deployment
    • Support for Git-powered release on on PythonAnywhere

Front-end

  • Bootstrap-powered clean front-end
  • Elegant themes powered by https://bootswatch.com/
  • Ability to change themes on the fly
  • Sample Front-end Components (TODO)

Requirements

  • For package requirements, check requirements.txt
  • Mail functionality requires SMTP access.
  • For PythonAnywhere deployment, an account on https://www.pythonanywhere.com/ is required.
    • PythonAnywhere free accounts do not support non-HTTP(S) ports, this results in MongoDB, `
  • MySQL access required if MySQL is used as backend server.

Setup

Getting started with the basic application is straightforward.

  • Install the requirements from the requirements.txt,
$ pip3 install -r requirements.txt
  • Copy settings.sample.py to settings.py and update it as required.

Most of the settings can also be specified through environment variables. There are inline explanations in the settings file if the variables are not self-explanatory.

Run

Run the application using,

$ python server.py

OR

$ export FLASK_APP="server:webapp"
$ flask run

(Other WSGI-based deployments are also possible. e.g. gunicorn)

Database Support

By default, SQLite3 database will be used. To use MySQL, update credentials either through settings.py or through environment variables. In settings.py, set USE_SQLITE to False and USE_MYSQL to True.

Support for PostgreSQL, although not explicitly added, is easy to figure out. It can be achieved in a similar manner to MySQL support by installing the necessary driver and using the proper database_uri for SQLAlchemy.

MongoDB support may be added in the future, although it's not too difficult to figure it out.

Mail

If SMTP credentials are added, mail support will be enabled. This would enable password recovery by receiving a link for password reset, as well as a welcome mail after registration.

Contents of these emails can be modified by editing templates in tempaltes/security/email

PythonAnywhere Support

  • Create a free account on https://www.pythonanywhere.com/
  • Generate a token
  • Clone your repository on the server
  • Set-up your application by setting propery WSGI paths
  • Once your application is running, for future updates, you can use "Update" and "Reload" buttons from Admin tab to update your application.
  • For PythonAnywhere free accounts, only SMTP permitted is smtp.gmail.com.

Contribute

Aim of this project is to provide a basic skeleton for development of simple, beautiful and functional web applications.

Feel free to contribute towards that end by,

  • Providing new features
  • Improving current features
  • Improving code quality
  • Adding documentation

License

GNU GPL v3

flask-bootstrap-anywhere's People

Contributors

deflateawning avatar hrishikeshrt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flask-bootstrap-anywhere's Issues

old dependencies and potential security issues

  1. "flask-restx 1.2.0 requires Flask!=2.0.0,<3.0.0,>=0.8, but you have flask 3.0.0 which is incompatible."

2/. "cannot import name 'url_decode' from 'werkzeug.urls'", which fixed to downgrade:

pip uninstall werkzeug
pip install werkzeug==2.3.0

Database error after trying to use (Query-invoked autoflush)

  1. Use this repo to create another repo, clone it, etc.
  2. Create a venv: python3 -m venv venv
  3. Activate the venv
  4. Install requirements from the requirements.txt file (which result in much newer requirements being installed): pip install -r requirements.txt
  5. Export the env from the README.
  6. Run flask db init and flask db migrate and flask db upgrade.
  7. Run flask run.
  8. Load the homepage.
  9. Observe the following error:
sqlalchemy.exc.InterfaceError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(sqlite3.InterfaceError) Error binding parameter 3 - probably unsupported type.
[SQL: INSERT INTO role (name, description, level, permissions) VALUES (?, ?, ?, ?)]
[parameters: ('owner', 'Owner', 1000, ['view_acp', 'remove_admin'])]
(Background on this error at: https://sqlalche.me/e/14/rvf5)

This is the pip freeze output:

alembic==1.8.1
Babel==2.11.0
blinker==1.5
certifi==2022.9.24
charset-normalizer==2.1.1
click==8.1.3
colorama==0.4.6
dnspython==2.2.1
email-validator==1.3.0
Flask==2.2.2
Flask-BabelEx==0.9.4
Flask-Login==0.6.2
Flask-Mail==0.9.1
Flask-Migrate==4.0.0
Flask-Principal==0.4.0
Flask-Security-Too==5.0.2
Flask-SQLAlchemy==3.0.2
Flask-WTF==1.0.1
gitdb==4.0.9
GitPython==3.1.29
greenlet==2.0.1
idna==3.4
importlib-metadata==5.0.0
importlib-resources==5.10.0
itsdangerous==2.1.2
Jinja2==3.1.2
Mako==1.2.4
MarkupSafe==2.1.1
passlib==1.7.4
pytz==2022.6
requests==2.28.1
smmap==5.0.0
speaklater==1.3
SQLAlchemy==1.4.44
urllib3==1.26.12
Werkzeug==2.2.2
WTForms==3.0.1
zipp==3.10.0
  • Using SQLite

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.