# coding=utf-8 """ define all of api's URL """ from flask import Blueprint from rmon.views.index import IndexView from rmon.views.server import ServerList api = Blueprint("api", __name__) api.add_url_rule("/", view_func=IndexView.as_view("index")) api.add_url_rule("/servers/", view_func=ServerList.as_view("server_list"))
#定义 路由 from flask import Blueprint from rmon.views.index import IndexView #名为api 的蓝图 api = Blueprint('api', __name__) # api 的路由 为 ‘/’,访问/时调用 IndexView 处理 GET, POST # 通过url_for(‘api.indx'),获得对应的URL api.add_url_rule('/', view_func=IndexView.as_view('index'))
定义了所有 API 对应的 URL """ from flask import Blueprint from rmon.views.index import IndexView from rmon.views.server import (ServerCommand, ServerDetail, ServerList, ServerMetrics) from rmon.views.user import UserList, UserDetail from rmon.views.auth import AuthView, RefreshTokenView from rmon.views.wx import WxView, WxBind api = Blueprint('api', __name__) # 首页 api.add_url_rule('/', view_func=IndexView.as_view('index')) # 登录 api.add_url_rule('/login', view_func=AuthView.as_view('login')) api.add_url_rule('/token/refresh', view_func=RefreshTokenView.as_view('refresh_token')) # 用户管理 api.add_url_rule('/users/', view_func=UserList.as_view('user_list')) api.add_url_rule('/users/<int:object_id>', view_func=UserDetail.as_view('user_detail')) # Redis 服务器管理 api.add_url_rule('/servers/', view_func=ServerList.as_view('server_list')) api.add_url_rule('/servers/<int:object_id>',