Ejemplo n.º 1
0
# author    : SC
# time      :2020/9/1  18:14
# file      :getData.PY
# project   :apiToy
# IDE       : PyCharm

import os
from app.libs.yellowprint import YellowPrint
from app.libs.db_manager import *
from app.libs.get_temperature import get_temperature_shanghai, update_current_temperature_to_mongodb
from flask import jsonify
from flask import request

yp_data = YellowPrint('yp_data', url_prefix='/data')


@yp_data.route('/all', methods=['GET'])
def get_all_data():
    return jsonify(get_all())


@yp_data.route('/company_info', methods=['GET'])
def get_company_info():
    return jsonify(get_company())


@yp_data.route('/floor_company', methods=['GET'])
def get_floor_info():
    return jsonify(get_floor())

Ejemplo n.º 2
0
import os
from flask import request
from app.authorization.token_auth import login_required, get_account_by_token
from app.libs.yellowprint import YellowPrint
from app.config.setting import UPLOAD_PATH
from app.validators.forms import TagForm, FilterForm, TagImageForm
from app.models.tag import Tag
from app.libs.error_code import ParameterException
from app.libs.error import NoException
import uuid

yp_tag = YellowPrint('yp_tag', url_prefix='/tag')


@yp_tag.route('/register', methods=['POST'])
# @login_required
def tag_register():
    # data = request.json
    # account = data['account']
    # password = data['password']

    # 1、request.data 会自动传入ClientForm
    form = TagForm()
    # 2、对TagForm对实例进行校验
    if form.validate():
        # 3.1、查询标签名是否已经存在
        if Tag.query.filter_by(name=form.name.data).first():
            # 4、如果标签名存在返回报错601
            return ParameterException(error_code=601, msg='标签名已经存在')
        else:
            # 5、若标签名不存在,尝试注册标签
Ejemplo n.º 3
0
from app.libs.yellowprint import YellowPrint
from app.authorization.token_auth import login_required
from flask import jsonify

yp_test = YellowPrint('yp_test', url_prefix='/test')


@yp_test.route('/test1', methods=['POST'])
def t_test():
    return 'f**k me11'


@yp_test.route('/testtest', methods=['POST'])
def t_test2():
    return 'OK'


@yp_test.route('/table')
# @login_required
def table_generation():
    return 'table'


@yp_test.route('/table1')
# @login_required
def table_generation1():
    resp = jsonify({'error': False})
    # 跨域设置
    resp.headers['Access-Control-Allow-Origin'] = '*'
    resp.headers['Access-Control-Allow-Method'] = '*'
    resp.headers[
Ejemplo n.º 4
0
from flask import request
from app.authorization.token_auth import login_required
from app.libs.yellowprint import YellowPrint
from app.validators.forms import ClientForm, FilterForm
from app.models.user import User
from app.libs.error_code import ParameterException
from app.libs.error import NoException
from app.authorization.token_auth import creat_token, verify_token

yp_user = YellowPrint('yp_user', url_prefix='/user')


@yp_user.route('/register', methods=['POST'])
@login_required
def user_register():
    # data = request.json
    # account = data['account']
    # password = data['password']

    # 1、request.data 会自动传入ClientForm
    form = ClientForm()
    # 2、对ClientForm对实例进行校验
    if form.validate():
        # 3.1、查询用户名是否已经存在
        if User.query.filter_by(account=form.account.data).first():
            # 4、如果用户名存在返回报错601
            return ParameterException(error_code=601, msg='用户名已经存在')
        else:
            # 5、若用户名不存在,尝试注册用户
            User.add_user(account=form.account.data,
                          password=form.password.data)
Ejemplo n.º 5
0
from app.libs.yellowprint import YellowPrint

yp_book = YellowPrint('rp_user', url_prefix='/book')


@yp_book.route('/set')
def set_book():
    return 'this is set book page'


@yp_book.route('/get')
def get_book():
    return 'this is get book page'