Esempio n. 1
0
from settings import app, api

from view.users import DashboardUsers, SingleUser, Users
from view.dashboards import Dashboards, SingleDashboard
from view.tasks import DashboardTasks, SingleTask
from view.comments import TaskComments

api.add_resource(Users, '/users')
api.add_resource(DashboardUsers, '/dashboards/<int:dash_id>/users')
api.add_resource(SingleUser, '/users/<int:user_id>')

api.add_resource(Dashboards, '/dashboards')
api.add_resource(SingleDashboard, '/dashboards/<int:dash_id>')

api.add_resource(DashboardTasks, '/dashboards/<int:dash_id>/tasks')
api.add_resource(SingleTask, '/tasks/<int:task_id>')

api.add_resource(TaskComments, '/tasks/<int:task_id>/comments')

if __name__ == "__main__":
    app.run(debug=True)
Esempio n. 2
0
from settings import api

# routes
from resources.Ping import Ping
api.add_resource(Ping, '/service/api/ping')

from resources.UserProfile import UserProfileList, UserProfileDetail
api.add_resource(UserProfileList, '/service/api/userprofile')
api.add_resource(UserProfileDetail, '/service/api/userprofile/<id>')

from resources.Book import BookList, BookDetail
api.add_resource(BookList, '/service/api/book')
api.add_resource(BookDetail, '/service/api/book/<id>')
Esempio n. 3
0
def routes(self):
    api.add_resource(add, '/add')
    api.add_resource(getall, '/get')
    api.add_resource(sayHi, '/hello')
Esempio n. 4
0
class Ejercicio2Resource(Resource):
    def get(self):
        from icmplib import ping
        if ping(os.environ.get('VYOS_IP'), count=1).is_alive:
            return {'ejercicio2': 'OK'}
        else:
            return {'ejercicio2': 'Error'}, 400


class Ejercicio3Resource(Resource):
    def get(self):
        import requests
        try:
            result = requests.get('http://172.20.0.3')
            if result.status_code == 200:
                return {'ejercicio3': 'OK'}
            else:
                return {'ejercicio3': 'Error'}, 400
        except:
            return {'ejercicio3': 'Error'}, 400


api.add_resource(Ejercicio1Resource, os.environ['EJERCICIO_1'])
api.add_resource(Ejercicio2Resource, os.environ['EJERCICIO_2'])
api.add_resource(Ejercicio3Resource, os.environ['EJERCICIO_3'])

if __name__ == "__main__":
    # As the app is running inside a container I need to publish using container IP address
    host_ip_address = socket.gethostbyname(socket.gethostname())
    app.run(host=host_ip_address, port=5000, debug=True)
Esempio n. 5
0
from settings import app, api
from views.users import AllUsers
from views.users import SingleUser


api.add_resource(AllUsers, '/users')
api.add_resource(SingleUser, "/user/<int:user_id>")


if __name__ == "__main__":
    app.run()
Esempio n. 6
0
from settings import Resource, api, jsonify
from crawlers.ms_crawler import MsCrawler


class Index(Resource):
    def get(self):
        return {"menssagem": "Bem Vindo a API Registro MS"}


class GetMS(Resource):
    def get(self, num_ms):
        ms = MsCrawler()
        response = ms.get_medicines(num_ms)
        return jsonify({"resposta_medicamento": response})


api.add_resource(Index, "/")
api.add_resource(GetMS, "/codigo_ms/<num_ms>")
Esempio n. 7
0
            'geojson': geojson
        }, 200

    def post(self):
        if not session.get('logged_in'):
            abort(401, message='Login required.')

        database_session = database.open_session()
        cursor = database_session.execute(
            'select geojson from mapbox where id=1')
        content = cursor.fetchone()[0]

        request_parser = reqparse.RequestParser()
        request_parser.add_argument('geojson', type=unicode)
        post_data = request_parser.parse_args()
        geojson = post_data.get('geojson', None)

        database_session.execute(
            'update mapbox set geojson=? where id=1', [geojson])
        database_session.commit()

        return {
            'geojson': geojson
        }, 201


api.add_resource(Text, '/edit/text/<string:identifier>')
api.add_resource(Image, '/edit/image/<string:identifier>')
api.add_resource(Container, '/edit/container/<string:identifier>')
api.add_resource(MapBox, '/edit/mapbox/geojson')
Esempio n. 8
0
            }, 200

        return self.send_email()


    def send_email(self):
        name = request.form.get('name')
        email_address = request.form.get('email')
        message = request.form.get('message')
        recipients = ['*****@*****.**']

        email = Message(
            'A message from teenypies.com',
            sender = '*****@*****.**',
            recipients = recipients
        )
        email.body = 'Name: %s\nEmail: %s\n\nMessage: %s' % (name,
            email_address, message)

        if environment == 'development':
            print email.body
        else:
            mail.send(email)

        return {
            'notification': 'Your message has been sent!'
        }, 201


api.add_resource(EmailOrder, '/email-order')
Esempio n. 9
0
from settings import app, api

from views.dashboards import DashBoard, DashBoards, DashBoardUsers,\
    DashBoardTasks
from views.tasks import Task, SingleTask, Tasks, TaskMasterUser, TaskUsers,\
    TaskComment, TaskStatus, TaskWithStatus
from views.users import User, Users, SingleUser

api.add_resource(Users, '/users')
api.add_resource(SingleUser, '/users/<int:user_id>')

api.add_resource(DashBoards, '/dashboards')
api.add_resource(DashBoardUsers, '/dashboards/<int:dashboard_id>/users')
api.add_resource(DashBoardTasks, '/dashboards/<int:dashboard_id>/tasks')

api.add_resource(Tasks, '/tasks')
api.add_resource(SingleTask, '/tasks/<int:task_id>')
api.add_resource(TaskMasterUser, '/tasks/<int:task_id>/master')
api.add_resource(TaskUsers, '/tasks/<int:task_id>/users')
api.add_resource(TaskComment, '/tasks/<int:task_id>/comment')
api.add_resource(TaskStatus, '/tasks/<int:task_id>/status')
api.add_resource(TaskWithStatus, '/tasks/<string:status>')

if __name__ == "__main__":
    app.run()
Esempio n. 10
0
from settings import app, api

from view.users import Users, SihgleUser
from view.tasks import Tasks, SingleTask, AssignTask
from view.dashboards import Dashboards, SingleDashboard, CreateDashboard

api.add_resource(Users, "/users")
api.add_resource(SihgleUser, "/users/<int:user_id>")

api.add_resource(Tasks, "/tasks")
api.add_resource(SingleTask, "/tasks/<int:task_id>")
api.add_resource(AssignTask, "/task/assign/<int:task_id>")

api.add_resource(CreateDashboard, "/dashboards/create/<int:user_id>")
api.add_resource(Dashboards, "/dashboards")
api.add_resource(SingleDashboard, "/dashboards/<int:dashboard_id>")

if __name__ == "__main__":
    app.run(port=5003, debug=True)
Esempio n. 11
0
from settings import app,api
from resources import *

#Comments Urls

api.add_resource(New_Movie_Review, '/review/new/<movie_id>')
api.add_resource(Edit_Review, '/review/edit/<review_id>')
api.add_resource(Get_Movie_Reviews, '/reviews/get/<movie_id>')
api.add_resource(New_Movie, '/movie/new')
api.add_resource(Edit_Movie, '/movie/edit/<movie_id>')
api.add_resource(Get_Movie_Details, '/movie/get/<movie_id>')
api.add_resource(Get_Movies, '/movies/get')
api.add_resource(Get_Recommendation, '/movies/recommendations/<user_id>')
api.add_resource(Review_Summarization, '/reviews/summarization/<movie_id>')
api.add_resource(New_User, '/new/user')


if __name__ == '__main__':
    app.run('127.0.0.1', 8000)
Esempio n. 12
0
from settings import api
from views.todo_views import TodoListView, TodoEditView, TodoCreateView
from views.event_views import EventListView, EventEditView, EventCreateView

# TODOS ROUTES
api.add_resource(TodoListView, '/api/v1/todo/list')
api.add_resource(TodoCreateView, '/api/v1/todo/create')
api.add_resource(TodoEditView, '/api/v1/todo/<int:todo_id>')

# EVENT ROUTES
api.add_resource(EventListView, '/api/v1/event/list')
api.add_resource(EventCreateView, '/api/v1/event/create')
api.add_resource(EventEditView, '/api/v1/event/<int:event_id>')
Esempio n. 13
0
from settings import app, api
from views.school import MySchool
from views.courses import SingleCourse, Courses, CourseModules, \
    CourseTeacher, CourseStudents
from views.modules import Modules, SingleModule, ModuleCourse
from views.teachers import Teachers, SingleTeacher, TeacherCourse, \
    TeacherStudents
from views.students import Students, SingleStudent, \
    StudentCourse, StudentModule, StudentTeacher

api.add_resource(MySchool, '/school')

api.add_resource(Courses, "/courses")
api.add_resource(SingleCourse, "/courses/<int:course_id>")
api.add_resource(CourseModules, "/courses/<int:course_id>/modules")
api.add_resource(CourseTeacher, "/courses/<int:course_id>/teacher")
api.add_resource(CourseStudents, "/courses/<int:course_id>/students")

api.add_resource(Modules, "/modules")
api.add_resource(SingleModule, "/modules/<int:module_id>")
api.add_resource(ModuleCourse, "/modules/<int:module_id>/course")

api.add_resource(Teachers, "/teachers")
api.add_resource(SingleTeacher, "/teachers/<int:teacher_id>")
api.add_resource(TeacherCourse, "/teachers/<int:teacher_id>/course")
api.add_resource(TeacherStudents, "/teachers/<int:teacher_id>/students")

api.add_resource(Students, "/students")
api.add_resource(SingleStudent, "/students/<int:student_id>")
api.add_resource(StudentCourse, "/students/<int:student_id>/course")
api.add_resource(StudentTeacher, "/students/<int:student_id>/teacher")
Esempio n. 14
0
#########################END CLICKS SECTION#########################

#########################START DEVICES SECTION#########################

class ADevice(Resource):
      def post(self, position):
            NewDevice = Device(position)
            db.session.add(NewDevice)
            db.session.commit()
            return NewDevice.json(),201

#########################END DEVICES SECTION#########################

#-------------ROUTING-------------#
api.add_resource(Premises, '/premises/premises_id="<string:premises_id>"&short_desc="<string:short_description>"')   
api.add_resource(DeletePostPremises, '/premises/Dp/premises_id="<string:premises_id>"')
api.add_resource(ShowAllPremises, '/premises/All')
api.add_resource(PostClick, '/click/id="<int:pass_through>"')
api.add_resource(ADevice, '/device/position="<int:position>"')

@app.route('/')
def home():
      timestamp = datetime.now()
      premises = A_premises.query.all()
      devices = Device.query.all()
      clicks = Click.query.all()
      return render_template('index.html',Jtimestamp = timestamp,
                              Jpremises = premises,
                              Jdevices = devices,
                              Jclicks = clicks
Esempio n. 15
0
from settings import app, api
from views.products import Book, BookById, BookByGenre, BookByAuthor
from views.categories import Genre

api.add_resource(Book, '/books')
api.add_resource(Genre, '/genres')

api.add_resource(BookByGenre, '/genres/books/<int:id_>')
api.add_resource(BookById, '/books/<int:id_>')
api.add_resource(BookByAuthor, '/books/<author>')

if __name__ == '__main__':
    app.run(debug=True)
Esempio n. 16
0
from settings import app, api
from views.users import Users, SingleUser, UserStats
from views.dashboards import Dashboards, SingleDashboard, DashboardUsers, \
    DashboardTasks, DashboardStats, DashboardUsersDetailed
from views.user_dashboards import UserDashboards, UserDashboardsDetailed
from views.user_tasks import UserTasksDetailed, UserTaskComments, UserTasks
from views.tasks import Tasks, TaskUsers, TaskComments, TaskCommentsDetailed
from views.events import Events, UserSubscriptions, EventSubscribers

api.add_resource(Users, '/users')
api.add_resource(SingleUser, '/users/<int:user_id>')
api.add_resource(UserStats, '/users/<int:user_id>/data')

api.add_resource(Dashboards, '/dashboards')
api.add_resource(SingleDashboard, '/dashboards/<int:dashboard_id>')
api.add_resource(DashboardUsers, '/dashboards/<int:dashboard_id>/users')
api.add_resource(DashboardUsersDetailed,
                 '/dashboards/<int:dashboard_id>/users/<int:user_id>')
api.add_resource(DashboardTasks, '/dashboards/<int:dashboard_id>/tasks')
api.add_resource(DashboardStats, '/dashboards/<int:dashboard_id>/data')

api.add_resource(Tasks, '/tasks/<int:task_id>')
api.add_resource(TaskUsers, '/tasks/<int:task_id>/users')
api.add_resource(TaskComments, '/tasks/<int:task_id>/comments')
api.add_resource(TaskCommentsDetailed, '/comments/<int:comment_id>')

api.add_resource(UserDashboards, '/users/<int:user_id>/dashboards')
api.add_resource(UserDashboardsDetailed,
                 '/users/<int:user_id>/dashboards/<int:dashboard_id>')

api.add_resource(UserTasks,