Skip to content

Commit

Permalink
Added contract swagger api not working due to werkzeug
Browse files Browse the repository at this point in the history
  • Loading branch information
devendew committed Jun 8, 2021
1 parent 776884f commit 8d1d59f
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
<small>[Compare with latest](https://github.com/Dev121212/tess-main/compare/5b6c2eee4338c409a598a26f116ef31c1cc1168d...HEAD)</small>

### Added
- Adding changelog changes ([776884f](https://github.com/Dev121212/tess-main/commit/776884f32847ffea88cffb51727d08a422d2b807) by Devendra Dewangan).
- Added changelog.md ([39ddb8b](https://github.com/Dev121212/tess-main/commit/39ddb8b592dea9a5a507d8cd24f014246b85f47e) by Devendra Dewangan).


Binary file added __pycache__/app.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/views.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/views.cpython-38.pyc
Binary file not shown.
15 changes: 14 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import os
import sys
from flask import Flask

import views
from flask import Flask, jsonify
from werkzeug.utils import cached_property

from blueprints.basic_endpoints import blueprint as basic_endpoints

from blueprints.basic_endpoints import blueprint as basic_endpoint
from blueprints.documented_endpoints import blueprint as documented_endpoint


app = Flask(__name__)
app.config['RESTPLUS_MASK_SWAGGER'] = False

app.register_blueprint(basic_endpoints)
app.register_blueprint(documented_endpoint)

app.add_url_rule("/", view_func=views.root, methods=['GET'])
app.add_url_rule("/read_ocr", view_func=views.read_ocr, methods=['POST'])
print("Server Ready", flush=True)
Expand Down
18 changes: 18 additions & 0 deletions blueprints/basic_endpoints/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from flask import Blueprint, request

blueprint = Blueprint('api', __name__, url_prefix='/api')


@blueprint.route('/', methods=['GET'])
def root():
return {'message': 'Root!'}


@blueprint.route('/read_ocr', methods=['POST'])
def read_ocr():
if request.method == "POST":
return {
'message': 'This endpoint should create an entity',
'method': request.method,
'body': request.json
}
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions blueprints/documented_endpoints/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from flask import Blueprint
from flask_restplus import Api
from blueprints.documented_endpoints.hello_world import namespace as hello_world_ns

blueprint = Blueprint('documented_api', __name__, url_prefix='/documented_api')

api_extension = Api(
blueprint,
title='Flask RESTplus Demo',
version='1.0',
description='Application tutorial to demonstrate Flask RESTplus extension\
for better project structure and auto generated documentation',
doc='/doc'
)

api_extension.add_namespace(hello_world_ns)
Binary file not shown.
Binary file not shown.
24 changes: 24 additions & 0 deletions blueprints/documented_endpoints/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from flask import request
from flask_restplus import Namespace, Resource, fields

namespace = Namespace('hello_world', 'Hello World related endpoints')

hello_world_model = namespace.model('HelloWorld', {
'message': fields.String(
readonly=True,
description='Hello world message'
)
})

hello_world_example = {'message': 'Hello World!'}


@namespace.route('')
class HelloWorld(Resource):

@namespace.marshal_list_with(hello_world_model)
@namespace.response(500, 'Internal Server error')
def get(self):
'''Hello world message endpoint'''

return hello_world_example
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Pillow==8.2.0
pytesseract==0.3.7
requests==2.25.1
urllib3==1.26.5
Werkzeug==2.0.1
Werkzeug==0.16.0

0 comments on commit 8d1d59f

Please sign in to comment.