Skip to content

Commit

Permalink
Update to Flask==2.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
luk1337 committed Sep 16, 2023
1 parent 9fff666 commit d7a738f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 1 addition & 2 deletions api_v1.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from flask import Blueprint, jsonify, request

from api_common import get_builds, get_device_version, get_build_types, get_device_builds
from changelog.gerrit import GerritServer, GerritJSONEncoder
from changelog.gerrit import GerritServer
from changelog import get_changes, get_timestamp
from config import Config

import extensions

api = Blueprint('api_v1', __name__)
api.json_encoder = GerritJSONEncoder

gerrit = GerritServer(Config.GERRIT_URL)

Expand Down
2 changes: 2 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from prometheus_client import multiprocess, generate_latest, CollectorRegistry, CONTENT_TYPE_LATEST, Counter, Histogram

from api_common import get_device_builds, get_oems, get_device_data
from changelog.gerrit import GerritJSONProvider
from custom_exceptions import DeviceNotFoundException, UpstreamApiException
from config import Config
from api_v1 import api as api_v1
Expand All @@ -19,6 +20,7 @@
app.config.from_object('config.FlaskConfig')
app.register_blueprint(api_v1, url_prefix='/api/v1')
app.register_blueprint(api_v2, url_prefix='/api/v2')
app.json = GerritJSONProvider(app)
app.url_map.strict_slashes = False
extensions.setup(app)

Expand Down
6 changes: 3 additions & 3 deletions changelog/gerrit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
from __future__ import absolute_import

from datetime import datetime
from flask.json import JSONEncoder
from flask.json.provider import DefaultJSONProvider

import json
import requests


class GerritJSONEncoder(JSONEncoder):
class GerritJSONProvider(DefaultJSONProvider):
def default(self, obj):
try:
if isinstance(obj, GerritUser):
return {'id': obj.id, 'name': obj.name, 'username': obj.username, 'avatars': obj.avatars}
except TypeError:
pass
return JSONEncoder.default(self, obj)
return super().default(obj)


def parse_gerrit_datetime(d):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ certifi==2023.7.22
chardet==5.2.0
charset-normalizer==3.2.0
click==8.1.7
Flask==2.2.5
Flask==2.3.3
Flask-Caching==2.0.2
Flask-Cors==4.0.0
gunicorn==21.2.0
Expand Down

0 comments on commit d7a738f

Please sign in to comment.