Skip to content

Commit

Permalink
feat: flask resftul app setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Mala1180 committed Mar 10, 2024
1 parent 967ae70 commit 7a39b0f
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from flask import Flask

from app.resources.answers import answers_bp
from app.resources.questions import questions_bp


def create_app():
app = Flask(__name__)
app.register_blueprint(answers_bp)
app.register_blueprint(questions_bp)
return app
File renamed without changes.
21 changes: 21 additions & 0 deletions app/resources/answers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from flask import Blueprint
from flask_restful import Api, Resource

answers_bp = Blueprint('answers', __name__)
api = Api(answers_bp)


class Answer(Resource):

def get(self, answer_id=None):
if answer_id:
return "<h1>Answer for user with id {}</h1>".format(answer_id)
else:
pass

def post(self):
# Implement POST method
pass


api.add_resource(Answer, '/answers', '/answers/<int:answer_id>')
21 changes: 21 additions & 0 deletions app/resources/questions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from flask import Blueprint
from flask_restful import Api, Resource

questions_bp = Blueprint('questions', __name__)
api = Api(questions_bp)


class Question(Resource):

def get(self, question_id=None):
if question_id:
return "<h1>Question for user with id {}</h1>".format(question_id)
else:
pass

def post(self):
# Implement POST method
pass


api.add_resource(Question, '/questions', '/questions/<int:question_id>')
3 changes: 3 additions & 0 deletions docs/api/schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ components:
Answer:
type: object
properties:
id:
type: integer
description: The unique identifier for the answer
value:
type: string
description: The value of the answer
Expand Down

0 comments on commit 7a39b0f

Please sign in to comment.