Skip to content

Commit

Permalink
Initial commit for the project focusing on implementing REST APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
faizanxmulla committed Jan 11, 2024
1 parent 09de2a3 commit 7d8fe82
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
47 changes: 47 additions & 0 deletions template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from flask import Flask, jsonify, request
from flask_restful import Api, Resource
from flasgger import Swagger

app = Flask(__name__)
api = Api(app)
swagger = Swagger(app)


class Uppercase(Resource):

def get(self):

"""
This method responds to the GET request for this endpoint and returns the data in uppercase.
---
tags:
- Text Processing
parameters:
- name: text
in: query
type: string
required: true
description: The text to be converted to uppercase
responses:
200:
description: A successful GET request
content:
application/json:
schema:
type: object
properties:
text:
type: string
description: The text in uppercase
"""

text = request.args.get("text")

return {"text": text.upper()}, 200


api.add_resource(Uppercase, "/uppercase")


if __name__ == "__main__":
app.run(debug=True)
9 changes: 9 additions & 0 deletions testing_api_req.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import requests

base_url = 'http://127.0.0.1:5000/text-processing'

params = {'text': 'my name is ... '}

requests = requests.get(base_url, params=params)

print(requests.content, requests.json())

0 comments on commit 7d8fe82

Please sign in to comment.