Framework | Input Validation | Output Validation | Typing | Support | Community | Documentation | Stars |
---|---|---|---|---|---|---|---|
Flask-apispec | webargs | Marshmallow | Average | Creator | OK | Poor | 325 |
flask-rest-api | webargs | Marshmallow | Average | Research center | Small | OK | 90 |
Flask-RESTPlus | Custom | Custom | Average | Abandonned | Good | OK | 1400 |
Flask-Rebar | Marshmallow | Marshmallow | Average | Company | None | Good | 50 |
Connexion | OpenAPI | OpenAPI | Low | Company | Excellent | Good | 2000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@bp.app_errorhandler(Exception) | |
def handle_exception(e): | |
if type(e) == json.JSONDecodeError: | |
message=f"Unexpected JSON object: {e.doc}" | |
elif type(e) == APIException: | |
message=f"APIError due to API answer: {e.response}" | |
else: | |
message=f"Unexpected error: {type(e).__name__}" | |
import traceback |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FlagApi(Resource): | |
def get(self): | |
return jsonify({'status':'err','description':Config.FLAG_ONE}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@bp.route("/<school_name>/course/<course_id>") | |
@valid_school | |
def grades(school_name, course_id): | |
grades = _api(f'/course/{course_id}') | |
if grades == {}: | |
return render_template("error.html", message="Course not found") | |
return render_template("grades.html", school_name=school_name, | |
grades=grades['grades'], | |
course_name=grades['course_name']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### BASE ### | |
FROM node:12-buster-slim AS base | |
RUN apt-get update && apt-get install --no-install-recommends --yes openssl | |
WORKDIR /app | |
### BUILDER ### | |
FROM base AS builder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_body_reader(self): | |
chunked = False | |
content_length = None | |
for (name, value) in self.headers: | |
if name == "CONTENT-LENGTH": | |
content_length = value | |
elif name == "TRANSFER-ENCODING": | |
chunked = value.lower() == "chunked" | |
elif name == "SEC-WEBSOCKET-KEY1": | |
content_length = 8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curr = lines.pop(0) | |
header_length = len(curr) | |
if curr.find(":") < 0: | |
raise InvalidHeader(curr.strip()) | |
name, value = curr.split(":", 1) | |
name = name.rstrip(" \t").upper() | |
if HEADER_RE.search(name): | |
raise InvalidHeaderName(name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask_rebar import errors | |
from .app import registry | |
from .schemas import HealthSchema | |
@registry.handles(rule="/health", method="GET", marshal_schema=HealthSchema()) | |
def get_health(): | |
return {"status": "OK"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask_rebar import Rebar | |
rebar = Rebar() | |
registry = rebar.create_handler_registry(prefix='/api') | |
def create_app() -> Flask: | |
app = Flask(__name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from marshmallow import fields, Schema | |
class HealthSchema(Schema): | |
status = fields.String() |
NewerOlder