cd ~ # virtualenv env # . env/bin/activate mkdir -p ~/www/my_app cd www git clone https://github.com/Alexmod/Flask-User-and-Flask-admin.git my_app cd my_app/ # pip install -r requirements.txt # python manage.py init_db # py.test tests/ # , python manage.py runserver
http://localhost:5000/
should open the site as in the screenshots. # local_settings.py BABEL_DEFAULT_LOCALE = 'ru'
app/translations/ru/LC_MESSAGES/flask_user.po
{%trans%}Forgot your Password?{%endtrans%} {{ _('Sign in') }}
import gettext
def set_lang(lang): i18n_dir = app.config['BABEL_TRANSLATION_DIRECTORIES'] gettext.install('lang', i18n_dir) trans_file = i18n_dir + lang + '/LC_MESSAGES/flask_user' tr = gettext.translation(trans_file, 'locale', languages=[lang]) tr.install(True) app.jinja_env.install_gettext_translations(tr)
{% import "bootstrap/utils.html" as utils %} {{ utils.flashed_messages(dismissible=True, container=False) }}
cd ~ # virtualenv env # . env/bin/activate # mkdir -p ~/www/my_app cd www git clone https://github.com/Alexmod/flask-security-flask-admin-mongodb.git my_app cd my_app # pip install -r requirements.txt # python manage.py runserver
http://localhost:5000/
should open the site as in the screenshots. pip install gunicorn
from app import create_app app = create_app()
gunicorn wsgi:app
http://127.0.0.1:8000
will be a site that can be bolted to nginx or apache. Next we configure systemd so that it starts automatically, and do not forget to change the line in the local_settings.py file: DEBUG = True # False
Source: https://habr.com/ru/post/349264/
All Articles