from flask import request, jsonify, send_from_directory from flask_restplus import Resource from api.api import api from application.admin.use_cases import register_admin, license_Emit ns = api.namespace('admins', description='Operations related to admin CRUD') @ns.route('/') @api.response(404, 'Request Invalid') @api.response(200, 'Success') class admin(Resource): def post(self): """Create a new student""" json_data = request.get_json(force=True) email = json_data['email'] password = json_data['password'] response = jsonify(register_admin(email=email, password=password)) response.headers.add("Access-Control-Allow-Origin", "*") return response @ns.route('/license/<int:id>') @api.response(404, 'Request Invalid') @api.response(200, 'Success') class license(Resource): def get(self, id): "Get student information for license emittion" names = license_Emit(id=id)
from api.api import api from flask_restplus import Resource, fields from flask import request, jsonify, make_response, Response from werkzeug.utils import secure_filename from api.implementation import upload_file, download_file, delete_file, send_email import sys # namespace sets the endpoints with a prefix of /users namespace = api.namespace('files', description='Operations on marketing resources') # Model for file operations file_model = namespace.model( "File", {"file": fields.String(description="File name", required=True)}, ) @namespace.route('/upload') class MarketingCollectionUpload(Resource): @api.doc(responses={201: 'File uploaded', 400: 'Error occurred'}) @namespace.expect(file_model) def post(self): """ Upload file """ if request.is_json and request.json["file"]: rc = upload_file(request.json) if rc == 1: return None, 400 else:
from flask import request, jsonify from flask_restplus import Resource, fields from api.api import api from application.instructor.use_cases import insert_new_instructor, delete_instructor, get_instructors_list, update_instructor, get_instructor, get_lesson_list from datetime import datetime, date from core.models import Instructor ns = api.namespace('instructors', description='Operations related to instructor CRUD') @ns.route('/') @api.response(404, 'Request Invalid.') @api.response(200, 'Success') class instructor(Resource): def get(self): """Returns a list of all instructors""" response = jsonify(get_instructors_list()) response.headers.add("Access-Control-Allow-Origin", "*") return response def post(self): """Create a new instructor""" json_data = request.get_json(force=True) name = json_data['name'] email = json_data['email'] password = json_data['password'] license_number = json_data['license_number']
from flask import request, jsonify from flask_restplus import Resource from api.api import api from application.student.use_cases import get_students_list, insert_new_student, get_student, delete_student, update_student, get_lesson_list from datetime import datetime, date ns = api.namespace('students', description='Operations related to student CRUD') @ns.route('/') @api.response(404, 'Request Invalid') @api.response(200, 'Success') class student(Resource): def get(self): """Returns a list of all students""" response = jsonify(get_students_list()) response.headers.add("Access-Control-Allow-Origin", "*") return response def post(self): """Create a new student""" json_data = request.get_json(force=True) name = json_data['name'] email = json_data['email'] password = json_data['password'] address = json_data['address'] birth_date = datetime.strptime(json_data['birth_date'], "%Y-%m-%d").date()
import logging from flask import request, jsonify, make_response from flask_restplus import Resource from api.action import BasicAction from api.api import api from schema.model import track_data, search_track, trackType log = logging.getLogger(__name__) ns = api.namespace('tracker', description='Operations to tracker') @ns.route('/') class TrackData(Resource): @api.expect(track_data) def post(self): """ Push a new tracker data """ return BasicAction.push(request.json), 200 @ns.route('/search') class TrackDataGet(Resource): @api.expect(search_track) def post(self): """ Search tracker data """
import cv2 from flask import send_file from flask_restplus import Resource from api.api import api from api.controlers.pictures import create_picture from api.serializers import picture, upload_parser from database.models import Picture import numpy as np from core.image_processing import compare_mask, mask_gt_and_pr log = logging.getLogger(__name__) ns = api.namespace('pictures', description='Operations related to pictures') DATA_DIR = './data' @ns.route('/') class PictureCollection(Resource): @api.marshal_list_with(picture) def get(self): """ Returns list of pictures. """ pictures = Picture.query.all() return pictures @api.response(201, 'Picture successfully created.')
# for debugging purposes from __future__ import print_function import sys from flask import request, jsonify from flask_restplus import Resource from api.api import api from application.login.use_cases import loginURL ns = api.namespace( 'login', description= 'Operations related to the login (for students, instructors and admins)') @ns.route('/') @api.response(404, 'Request Invalid') @api.response(200, 'Success') class login(Resource): def post(self): json_data = request.get_json(force=True) email = json_data['email'] password = json_data['password'] print(str(email) + ' ' + str(password), file=sys.stderr) response = jsonify(loginURL(email=email, password=password)) response.headers.add("Access-Control-Allow-Origin", "*") return response