Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle update imports #4

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,11 @@ coverage.xml
docs/_build/

main.db

*.xml
*.iml
*.idea

# Default ignored files
/shelf/
/workspace.xml
15 changes: 7 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/usr/bin/env python

from flask import Flask
from flask.ext.restful import Api

app = Flask(__name__)
api = Api(app)
from flask_restful import Api

from resources import TodoListResource
from resources import TodoResource

api.add_resource(TodoListResource, '/todos', endpoint='todos')
api.add_resource(TodoResource, '/todos/<string:id>', endpoint='todo')
app = Flask(__name__)
api = Api(app)

api.add_resource(TodoListResource, "/todos", endpoint="todos")
api.add_resource(TodoResource, "/todos/<string:id>", endpoint="todo")

if __name__ == '__main__':
if __name__ == "__main__":
app.run(debug=True)
26 changes: 13 additions & 13 deletions resources.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from flask_restful import abort
from flask_restful import fields
from flask_restful import marshal_with
from flask_restful import reqparse
from flask_restful import Resource

from models import Todo
from db import session

from flask.ext.restful import reqparse
from flask.ext.restful import abort
from flask.ext.restful import Resource
from flask.ext.restful import fields
from flask.ext.restful import marshal_with
from models import Todo

todo_fields = {
'id': fields.Integer,
'task': fields.String,
'uri': fields.Url('todo', absolute=True),
"id": fields.Integer,
"task": fields.String,
"uri": fields.Url("todo", absolute=True),
}

parser = reqparse.RequestParser()
parser.add_argument('task', type=str)
parser.add_argument("task", type=str)


class TodoResource(Resource):
@marshal_with(todo_fields)
Expand All @@ -37,7 +37,7 @@ def delete(self, id):
def put(self, id):
parsed_args = parser.parse_args()
todo = session.query(Todo).filter(Todo.id == id).first()
todo.task = parsed_args['task']
todo.task = parsed_args["task"]
session.add(todo)
session.commit()
return todo, 201
Expand All @@ -52,7 +52,7 @@ def get(self):
@marshal_with(todo_fields)
def post(self):
parsed_args = parser.parse_args()
todo = Todo(task=parsed_args['task'])
todo = Todo(task=parsed_args["task"])
session.add(todo)
session.commit()
return todo, 201