# -*- coding: utf-8 -*- """ :author: Shimada666 :url: https://github.com/shimada666 :copyright: © 2019 Shimada666 <*****@*****.**> :license: MIT, see LICENSE for more details. """ from app.libs.redprints import Redprint from app.libs.utils import common_render from app.models.friend_links import FriendLinks from app.exceptions.base import Success, NotFound from app.extensions import db from flask import request, flash friend_links_rp = Redprint('friend-links') @friend_links_rp.route('/list') def links_list(): links = FriendLinks.query.all() return common_render('page/links/list/index.html', links=links) @friend_links_rp.route('/add', methods=['GET', 'POST']) def links_add(): if request.method == 'POST': req = request.form.to_dict() f = FriendLinks(title=req['title'], url=req['url'], email=req['email'], create_time=req['create-time'])
from flask import Flask from flask import Blueprint from app.libs.redprints import Redprint # book = Blueprint('book', __name__) api = Redprint('book') # @book.route('/v1/book/get') # @api.route('/v1/book/get') # @api.route('/get') @api.route('', methods=['GET']) def get_book(): return 'this is a book'
""" :author: Shimada666 :url: https://github.com/shimada666 :copyright: © 2019 Shimada666 <*****@*****.**> :license: MIT, see LICENSE for more details. """ from app.libs.redprints import Redprint from app.libs.utils import redirect_back_url, common_render, get_ep_infos, find_auth_module from app.libs.decorators import admin_required from app.validtors.forms import RegisterForm, NewGroup from app.extensions import db from app.models.user import User, Group, Auth from app.exceptions.base import NotFound, Success from flask import request, flash, redirect, url_for auth_rp = Redprint('auth') @auth_rp.route('/user/create', methods=['GET', 'POST']) @admin_required def create_user(): groups = Group.query.all() if request.method == 'POST': form = RegisterForm() if form.validate_on_submit(): exists = User.query.filter_by(username=form.username.data).first() if exists: flash('该用户已被使用,请输入其他的用户名!', 2) return common_render('page/manage_user/create/index.html') new_user = User(username=form.username.data, email=form.email.data,
from app.libs.redprints import Redprint from app.libs.utils import redirect_back_url, common_render from app.validtors.forms import LoginForm, ResetPasswordForm, UserInfoForm from app.models.user import User from app.extensions import db from app.exceptions.base import AuthFailed, Success from flask import request, render_template, redirect, url_for, flash, jsonify, get_flashed_messages from flask_login import current_user, login_user, logout_user, login_required user_rp = Redprint('user') @user_rp.route('/login', methods=['GET', 'POST']) def login(): if current_user.is_authenticated: flash('已登录!') return redirect(url_for('home.index')) if request.method == 'POST': form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(username=form.username.data.lower()).first() if user is not None and user.validate_password(form.password.data): flash('登录成功!', 1) login_user(user, True) return redirect(url_for('home.index')) else: flash('用户名或密码错误!', 2) else: flash(form.errors_info) return common_render('page/login/index.html')
from flask import Blueprint from app.libs.redprints import Redprint # user = Blueprint('user', __name__) api = Redprint('user') # @api.route('/get') @api.route('', methods=['GET']) def get_user(): return 'i am user vincent'
:copyright: © 2019 Shimada666 <*****@*****.**> :license: MIT, see LICENSE for more details. """ from app.libs.redprints import Redprint from app.libs.utils import redirect_back_url, common_render from app.validtors.forms import LoginForm, ResetPasswordForm from app.models.user import User from app.extensions import db from app.exceptions.base import AuthFailed, Success from flask import request, render_template, redirect, url_for, flash, jsonify from flask_login import current_user, login_user, logout_user, login_required import os import platform system_rp = Redprint('system') @system_rp.route('/navs') def navs(): if current_user.is_authenticated and current_user.is_admin: res = [ { "title": "后台首页", "icon": "icon-computer", "href": f"{url_for('demo.main_page')}", "spread": False }, { "title": "用户管理",
from app.libs.redprints import Redprint api = Redprint('client') @api.route('/register') def create_clinet(): return 'regist client'