from app.server import api, app from app.models import db class ShowIndex(View): def dispatch_request(self): return render_template('index.html') class Website(Resource): def post(self): json_data = request.get_json(force=True) rs = RemoteServer(json_data['ip'], json_data['pass']) db.session.add(rs) db.session.commit() return {'server_id' : rs.id} def get(self): resp = RemoteServer.Schema(many=True).dump(RemoteServer.query.all()) print resp.data return resp.data class WebsiteSpecific(Resource): def get(self, site_id): item = RemoteServer.Schema().dump(RemoteServer.query.get(site_id)).data print item if not item: return abort(500) return item api.add_resource(Website, '/api/website') api.add_resource(WebsiteSpecific, '/api/website/<int:site_id>') app.add_url_rule('/', view_func=ShowIndex.as_view('show_index'))
return lista_gastos class GastoView(restful.Resource): @marshal_with(gasto_json) def get(self, id): gasto = Gasto.query.filter_by(id=id).first() return gasto @marshal_with(gasto_json) def patch(self, id): gasto = Gasto.query.filter_by(id=id).first() for campo_editado in request.get_json(): print campo_editado for key, val in campo_editado.items(): setattr(gasto, key, val) db.session.commit() class MenuList(restful.Resource): @marshal_with(menu_json) def get(self): return [{'nome': 'gastos'}, {'nome': 'relatorios'}] api.add_resource(GastoListView, '/api/v1/gastos') api.add_resource(GastoView, '/api/v1/gastos/<int:id>') api.add_resource(MenuList, '/api/v1/menus')
return form.errors, 422 column = Column.query.filter_by(id=id).first() column.name = form.name.data column.description = form.description.data db.session.commit() return ColumnSerializer(column).data, 201 def delete(self, id): column = Column.query.filter_by(id=id).first() db.session.delete(column) db.session.commit() columns = Column.query.all() return ColumnSerializer(columns, many=True).data api.add_resource(UserView, '/api/v1/users') api.add_resource(SessionView, '/api/v1/sessions') api.add_resource(PostListView, '/api/v1/posts') api.add_resource(PostView, '/api/v1/posts/<int:id>') api.add_resource(ToDoListView, '/api/v1/todos') api.add_resource(ToDoView, '/api/v1/todos/<int:id>') api.add_resource(ContactListView, '/api/v1/contacts') api.add_resource(ContactView, '/api/v1/contacts/<int:id>') api.add_resource(ProjectListView, '/api/v1/projects') api.add_resource(ProjectView, '/api/v1/projects/<int:id>') api.add_resource(IssueListView, '/api/v1/issues') api.add_resource(IssueView, '/api/v1/issues/<int:id>') api.add_resource(TagListView, '/api/v1/tags') api.add_resource(TagView, '/api/v1/tags/<int:id>') api.add_resource(MilestoneListView, '/api/v1/milestones') api.add_resource(MilestoneView, '/api/v1/milestones/<int:id>')
from app.resources.StateResource import GetPhasesResource from app.resources.StateResource import GetGameState from app.resources.DraftResource import DraftPickResource @app.route('/', defaults={'path': ''}) @app.route('/<path:path>') def catch_all(path): print("app/static/{}".format(path)) if Path("app/static/{}".format(path)).is_file(): return app.send_static_file(path) else: return app.send_static_file('index.html') api.add_resource(TeamResource, '/api/team/<team_id>') api.add_resource(TeamRosterResource, '/api/team/<team_id>/roster') api.add_resource(TeamsResource, '/api/team') api.add_resource(RetireResource, '/api/player/retire') api.add_resource(FreeAgentsResource, '/api/player/freeAgents') api.add_resource(FormationResource, '/api/formation') api.add_resource(GetRegularSeasonResource, '/api/schedule') api.add_resource(GetTeamRegularSeasonResource, '/api/schedule/<team_id>') api.add_resource(PlayRegularSeasonResource, '/api/schedule/play') api.add_resource(GetNextWeekResource, '/api/schedule/nextWeek/<team_id>') api.add_resource(GetLastWeekResource, '/api/schedule/lastWeek/<team_id>') api.add_resource(PlayNextWeekResource, '/api/schedule/nextWeek/play')
if not form.validate_on_submit(): return form.errors, 422 column = Column.query.filter_by(id=id).first() column.name = form.name.data column.description = form.description.data db.session.commit() return ColumnSerializer(column).data, 201 def delete(self, id): column = Column.query.filter_by(id=id).first() db.session.delete(column) db.session.commit() columns = Column.query.all() return ColumnSerializer(columns, many=True).data api.add_resource(UserView, '/api/v1/users') api.add_resource(SessionView, '/api/v1/sessions') api.add_resource(PostListView, '/api/v1/posts') api.add_resource(PostView, '/api/v1/posts/<int:id>') api.add_resource(ToDoListView, '/api/v1/todos') api.add_resource(ToDoView, '/api/v1/todos/<int:id>') api.add_resource(ContactListView, '/api/v1/contacts') api.add_resource(ContactView, '/api/v1/contacts/<int:id>') api.add_resource(ProjectListView, '/api/v1/projects') api.add_resource(ProjectView, '/api/v1/projects/<int:id>') api.add_resource(IssueListView, '/api/v1/issues') api.add_resource(IssueView, '/api/v1/issues/<int:id>') api.add_resource(TagListView, '/api/v1/tags') api.add_resource(TagView, '/api/v1/tags/<int:id>') api.add_resource(MilestoneListView, '/api/v1/milestones') api.add_resource(MilestoneView, '/api/v1/milestones/<int:id>')
print("user ", user.id, " current user ", g.user.id) print("You are not athorised to have access to user profile.") abort(403) return UserSerializer(user).data, 200 @auth.login_required def put(self, userid): form = ProfileUpdateForm() if not form.validate_on_submit(): return form.errors, 422 prof = User.query.filter_by(id=userid).first() # request.args.get('postid') if prof.id != g.user.id: abort(403) prof.email = form.email.data # set_password(self, form.password.data) db.session.commit() return UserSerializer(prof).data, 200 api.add_resource(UserView, '/api/v1/users') api.add_resource(SessionView, '/api/v1/sessions') api.add_resource(PostListView, '/api/v1/posts') api.add_resource(PostView, '/api/v1/posts/<int:id>') api.add_resource(CommentListView, '/api/v1/posts/<int:postid>/comments') api.add_resource(ManageComment, '/api/v1/usercomments/<int:userid>') api.add_resource(ManageComment2, '/api/v1/comments/<int:commentid>') api.add_resource(LogOut, '/api/v1/logout') api.add_resource(UserProfile, '/api/v1/profile/<int:userid>')