Update
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
CONFIG = 'config.demo'
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'http://remizoffalex.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
import config
|
||||
import logging
|
||||
@@ -19,9 +16,11 @@ app.config.from_object(config.CONFIG)
|
||||
app.config.from_envvar('FLASKR_SETTINGS', silent=True)
|
||||
|
||||
# Логирование
|
||||
handler = RotatingFileHandler(app.config['LOG_FILE'],
|
||||
handler = RotatingFileHandler(
|
||||
app.config['LOG_FILE'],
|
||||
maxBytes=app.config['LOG_FILE_SIZE']*1024*1024,
|
||||
backupCount=1)
|
||||
backupCount=1
|
||||
)
|
||||
handler.setLevel(logging.INFO)
|
||||
formatter = logging.Formatter(app.config['LONG_LOG_FORMAT'])
|
||||
handler.setFormatter(formatter)
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
from .users import LoginForm
|
||||
from .page import PageEdit
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'http://remizoffalex.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
from wtforms import (
|
||||
Form,
|
||||
BooleanField,
|
||||
TextField,
|
||||
PasswordField,
|
||||
TextAreaField
|
||||
)
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'http://remizoffalex.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
from wtforms import Form, TextField, PasswordField
|
||||
|
||||
from wtforms import Form, BooleanField, TextField, PasswordField
|
||||
|
||||
class LoginForm(Form):
|
||||
username = TextField('Имя пользователя')
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
from .pagination import Pagination, getpage
|
||||
from .passwd import pwgen, get_hash_password
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'http://remizoffalex.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
from flask import session, request
|
||||
from .. import app, models
|
||||
|
||||
def get_user():
|
||||
"""Получить текущего пользователя"""
|
||||
"""
|
||||
Получить текущего пользователя
|
||||
"""
|
||||
result = None
|
||||
if 'user_id' in session:
|
||||
result = models.db_session.query(
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
from math import ceil
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
def gettree(number, count=3):
|
||||
"""
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'http://remizoffalex.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'http://remizoffalex.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
import datetime
|
||||
from sqlalchemy import (
|
||||
@@ -23,6 +20,9 @@ from . import Base
|
||||
|
||||
|
||||
class User(Base):
|
||||
"""
|
||||
Пользователи
|
||||
"""
|
||||
__tablename__ = "user"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'http://remizoffalex.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
from flask_jsonrpc import JSONRPC
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'http://remizoffalex.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
from flask import abort, escape
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'http://remizoffalex.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
import os
|
||||
import jinja2
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'http://remizoffalex.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
from flask import render_template
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
from myapp import app
|
||||
from flask import Flask, render_template, request
|
||||
@@ -45,6 +43,9 @@ def edit():
|
||||
|
||||
@app.route('/login', methods=['GET', 'POST'])
|
||||
def login():
|
||||
"""
|
||||
Логин
|
||||
"""
|
||||
pagedata = {}
|
||||
pagedata['form'] = forms.LoginForm(request.form)
|
||||
body = render_template('login.html', pagedata=pagedata)
|
||||
|
||||
9
run.py
9
run.py
@@ -1,6 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
from myapp import app as application
|
||||
|
||||
application.run(debug = True, host= '0.0.0.0', port=8000)
|
||||
application.run(debug=True, host='0.0.0.0', port=8000)
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'http://remizoffalex.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
import os
|
||||
import sys
|
||||
@@ -18,8 +17,10 @@ from myapp import app, lib, models
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Скрипт добавления пользователя',
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Скрипт добавления пользователя',
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
||||
)
|
||||
parser._optionals.title = "Необязательные аргументы"
|
||||
|
||||
parser.add_argument("--user", dest="user", required=True, help="Новый пользователь")
|
||||
|
||||
3
wsgi.py
3
wsgi.py
@@ -1,10 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__copyright__ = '(c) RemiZOffAlex'
|
||||
__license__ = 'MIT'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
__url__ = 'http://remizoffalex.ru'
|
||||
__url__ = 'https://remizoffalex.ru'
|
||||
|
||||
from myapp import app as application
|
||||
|
||||
Reference in New Issue
Block a user