def add_resources(app): """ Method to add resources to app context Args: app (object): object of Flask representing the app in context """ api.add_resource(UserLogin, '/login') api.add_resource(LogoutAPI, '/logout') api.add_resource(UserSignUp, '/signup') api.add_resource(FacebookAuthorize, '/facebook') api.add_resource(GithubAuthorize, '/github')
parameters=[{ "name": "user", "required": True, "dataType": UserModel.__name__, "paramType": "body" }]) def post(self): parser = reqparse.RequestParser() parser.add_argument('username', type=str, help="user name") parser.add_argument('password', type=str, help="password") args = parser.parse_args() user = User.query.filter_by(name=args.username).first() if user is None: abort(401) login_user(user) return True api.add_resource(LoginApi, '/user/login') class LogoutApi(Resource): @swagger.operation(notes="login current user") def post(self): logout_user() api.add_resource(LogoutApi, '/user/logout')
def add_resources(app): """ Method to add resources to app context Args: app (object): object of Flask representing the app in context """ api.add_resource(UserLogin, "/login") api.add_resource(LogoutAPI, "/logout") api.add_resource(UserSignUp, "/signup") api.add_resource(FacebookAuthorize, "/facebook") api.add_resource(GithubAuthorize, "/github") api.add_resource(OneToMany, "/onetomany") api.add_resource(ManyToMany, "/manytomany") api.add_resource(ManyToManyChild, "/manytomanychild")
def add_resources(app): """ Method to add resources to app context Args: app (object): object of Flask representing the app in context """ api.add_resource(UserRegistration, '/registration') api.add_resource(Login, '/login') api.add_resource(Logout, '/logout') api.add_resource(Property, '/property') api.add_resource(EditProperty, '/edit_property') api.add_resource(DeleteProperty, '/delete_property') api.add_resource(Rented, '/rented')
class JWTUserModel(object): """ """ resource_fields = { 'username': fields.String, 'password': fields.String, 'captcha': fields.String } class JWTUserLoginApi(Resource): @swagger.operation(notes="JWT login", parameters=[{ 'name': 'user', 'required': True, 'dataType': JWTUserModel.__name__, 'paramType': 'body' }]) @jwt.auth_request_handler def post(self): parser = reqparse.RequestParser() parser.add_argument('username', type=str, required=True) parser.add_argument('password', type=str, required=True) parser.add_argument('captcha', type=str, required=True) args = parser.parse_args() api.add_resource(JWTUserLoginApi, '/jwt/user/login')
def add_resources(app): """ Method to add resources to app context Args: app (object): object of Flask representing the app in context """ api.add_resource(UserLogin, '/login') api.add_resource(LogoutAPI, '/logout') api.add_resource(UserSignUp, '/signup') api.add_resource(FacebookAuthorize, '/facebook') api.add_resource(GithubAuthorize, '/github') api.add_resource(JobDetails, '/jobdetails') api.add_resource(FilterCompany, '/filtercompany') api.add_resource(FilterTitle, '/filtertitle')
from flask_jwt import jwt_required from flask_restful import Resource from flask_restful_swagger import swagger from app.main import api class EverNone(Resource): @swagger.operation(notes="Get special note", parameters=[{ 'name': 'note_id', 'required': True, 'dataType': 'int', 'paramType': 'path' }, { 'name': 'authorization', 'required': True, 'dataType': 'str', 'paramType': 'header' }]) @jwt_required() def get(self, note_id): return {'id': note_id} api.add_resource(EverNone, '/evernote/<int:note_id>')
@marshal_with(CoffeeResource) def post(self): parser = reqparse.RequestParser() parser.add_argument('name', str, help="coffer's name") parser.add_argument('on_sale_date', type=custom_datetime) parser.add_argument('imported', type=compatible_bool) parser.add_argument('imported2', type=bool) args = parser.parse_args() coffee = Coffee(name=args.name, on_sale_date=args.on_sale_date, vendor_id=1, imported=args.imported) db.session.add(coffee) db.session.commit() return coffee api.add_resource(CoffeeApi, '/coffees') class Coffee2Api(Resource): @login_required @manager_required @swagger.operation(notes="Coffee list", parameters=filter_params()) @marshal_with(CoffeeResource) def get(self): return Coffee.query.paginate().items api.add_resource(Coffee2Api, '/coffees2')
from app.main import app from app.main import api from app.main.routes.society import SocietyApi from app.main.routes.user import UserApi from app.main.routes.user import UserListApi from app.main.routes.auth_controller import LoginAPI from app.main.routes.society import society app.register_blueprint(society) api.add_resource(SocietyApi, '/society', '/society/<int:soc_id>') api.add_resource(UserListApi, '/user') api.add_resource(UserApi, '/user/<int:public_id>') api.add_resource(LoginAPI, '/auth/login')
def add_resources(app): """ Method to add resources to app context Args: app (object): object of Flask representing the app in context """ api.add_resource(Register, '/user/register') api.add_resource(UserLogin, '/user/login') api.add_resource(LoginOtpGenerate, '/login/otp_generate') api.add_resource(LoginOtpVerify, '/login/otp_verify') api.add_resource(OauthLogin, '/login/oauth') api.add_resource(UserLogout, '/logout') api.add_resource(HotelListing, '/getproperty')
from flask_restful import Resource from flask_restful import reqparse from flask_restful_swagger import swagger from app.main import api from app.main.meta import UserModel from app.models import WxUser class WxUserApi(Resource): @swagger.operation(notes="wx user login", parameters=[{ "name": "user", "required": True, "dataType": UserModel.__name__, "paramType": "body" }]) def post(self): parser = reqparse.RequestParser() parser.add_argument('username', type=str, help="user name") parser.add_argument('password', type=str, help="password") args = parser.parse_args() user = WxUser.query.filter_by(wx_name=args.username).first() if user is None: abort(401) login_user(user) return True api.add_resource(WxUserApi, '/wx_user/login')