From dd1a28659251f8e69f48b7a34c22c5dd8436ae58 Mon Sep 17 00:00:00 2001 From: AlexeyDer Date: Wed, 22 Apr 2020 20:44:53 +0700 Subject: [PATCH 1/9] Add server example with serves badges --- server-example/app.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 server-example/app.py diff --git a/server-example/app.py b/server-example/app.py new file mode 100644 index 0000000..bb388bb --- /dev/null +++ b/server-example/app.py @@ -0,0 +1,26 @@ +# Example CI server that serves badges + +from flask import Flask +import pybadges + +app = Flask(__name__) + + +@app.route('/') +def serveBadges(): + # First example + badge_arg = dict( + left_text='build', + right_text='passing', + right_color='#008000' + ) + badge = pybadges.badge(**badge_arg) + + # Second example + secondBadge = pybadges.badge('chat', 'online') + + return badge + "\n" + secondBadge + + +if __name__ == '__main__': + app.run() From 0bd4d05dd9c4840cef93ef280d241e1e6a863a5d Mon Sep 17 00:00:00 2001 From: AlexeyDer Date: Thu, 23 Apr 2020 11:01:43 +0700 Subject: [PATCH 2/9] Add license, right comment and format code --- server-example/app.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/server-example/app.py b/server-example/app.py index bb388bb..94e7e20 100644 --- a/server-example/app.py +++ b/server-example/app.py @@ -1,4 +1,18 @@ -# Example CI server that serves badges +# Copyright 2018 The pybadge Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" Example CI server that serves badges """ from flask import Flask import pybadges @@ -12,13 +26,11 @@ def serveBadges(): badge_arg = dict( left_text='build', right_text='passing', - right_color='#008000' - ) + right_color='#008000') badge = pybadges.badge(**badge_arg) # Second example secondBadge = pybadges.badge('chat', 'online') - return badge + "\n" + secondBadge From 1cd743c771b16cad35c2a4004ac199b900c335f9 Mon Sep 17 00:00:00 2001 From: AlexeyDer Date: Thu, 23 Apr 2020 11:18:13 +0700 Subject: [PATCH 3/9] Add compact badge code write and response in images format --- server-example/app.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/server-example/app.py b/server-example/app.py index 94e7e20..d4789a9 100644 --- a/server-example/app.py +++ b/server-example/app.py @@ -16,22 +16,21 @@ from flask import Flask import pybadges +import flask app = Flask(__name__) @app.route('/') def serveBadges(): - # First example - badge_arg = dict( + badge = pybadges.badge( left_text='build', right_text='passing', right_color='#008000') - badge = pybadges.badge(**badge_arg) - # Second example - secondBadge = pybadges.badge('chat', 'online') - return badge + "\n" + secondBadge + response = flask.make_response(badge) + response.content_type = 'image/svg+xml' + return response if __name__ == '__main__': From 26c2b0b3b2efe44263dc7dfca318b0b5138a006f Mon Sep 17 00:00:00 2001 From: AlexeyDer Date: Thu, 23 Apr 2020 11:55:48 +0700 Subject: [PATCH 4/9] Add requirements.txt --- server-example/requirements.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 server-example/requirements.txt diff --git a/server-example/requirements.txt b/server-example/requirements.txt new file mode 100644 index 0000000..86b7b6c --- /dev/null +++ b/server-example/requirements.txt @@ -0,0 +1,25 @@ +asn1crypto==0.24.0 +click==7.1.1 +cryptography==2.1.4 +enum34==1.1.6 +Flask==1.1.2 +idna==2.6 +ipaddress==1.0.17 +itsdangerous==1.1.0 +Jinja2==2.11.2 +keyring==10.6.0 +keyrings.alt==3.0 +MarkupSafe==1.1.1 +mysql-connector-python==2.1.6 +mysql-utilities==1.6.4 +paramiko==2.0.0 +pexpect==4.2.1 +pyasn1==0.4.2 +pycrypto==2.6.1 +pygobject==3.26.1 +pyodbc==4.0.17 +pysqlite==2.7.0 +pyxdg==0.25 +SecretStorage==2.3.1 +six==1.11.0 +Werkzeug==1.0.1 From b369521db54f8e058d19cc864654f2e76373a389 Mon Sep 17 00:00:00 2001 From: AlexeyDer Date: Thu, 23 Apr 2020 13:21:09 +0700 Subject: [PATCH 5/9] Refresh requirements --- server-example/requirements.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/server-example/requirements.txt b/server-example/requirements.txt index 86b7b6c..f8451e3 100644 --- a/server-example/requirements.txt +++ b/server-example/requirements.txt @@ -1,9 +1,16 @@ +appdirs==1.4.3 asn1crypto==0.24.0 click==7.1.1 +configparser==4.0.2 +contextlib2==0.6.0.post1 cryptography==2.1.4 +distlib==0.3.0 enum34==1.1.6 +filelock==3.0.12 Flask==1.1.2 idna==2.6 +importlib-metadata==1.6.0 +importlib-resources==1.4.0 ipaddress==1.0.17 itsdangerous==1.1.0 Jinja2==2.11.2 @@ -13,6 +20,7 @@ MarkupSafe==1.1.1 mysql-connector-python==2.1.6 mysql-utilities==1.6.4 paramiko==2.0.0 +pathlib2==2.3.5 pexpect==4.2.1 pyasn1==0.4.2 pycrypto==2.6.1 @@ -20,6 +28,11 @@ pygobject==3.26.1 pyodbc==4.0.17 pysqlite==2.7.0 pyxdg==0.25 +scandir==1.10.0 SecretStorage==2.3.1 -six==1.11.0 +singledispatch==3.4.0.3 +six==1.14.0 +typing==3.7.4.1 +virtualenv==20.0.18 Werkzeug==1.0.1 +zipp==1.2.0 From 53cbc6e117f87e7ce901cf7303474fe12c0617da Mon Sep 17 00:00:00 2001 From: AlexeyDer Date: Thu, 23 Apr 2020 13:22:07 +0700 Subject: [PATCH 6/9] Add information about program in README.md --- server-example/README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 server-example/README.md diff --git a/server-example/README.md b/server-example/README.md new file mode 100644 index 0000000..7dba5e3 --- /dev/null +++ b/server-example/README.md @@ -0,0 +1,26 @@ +## Simple Server + +### Installing + +Before running, it is **recommended** to install the versions of packages that were used when writing this code: + +```sh +pip install -r requirements.txt +``` + +And if you don't have installed flask yet: + +```sh +apt install python3-flask +``` + +### Running + +You must inform the environment variable FLASK_APP and then run: + +```sh +export FLASK_APP=hello.py +flask run +``` + + * Running on http://127.0.0.1:5000/ \ No newline at end of file From 4a3dac9fcb28b94f24a2f31bb12e284f07211c25 Mon Sep 17 00:00:00 2001 From: AlexeyDer Date: Sat, 25 Apr 2020 00:18:59 +0700 Subject: [PATCH 7/9] Correct the description, remove unnecessary --- server-example/README.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/server-example/README.md b/server-example/README.md index 7dba5e3..6ec7b4c 100644 --- a/server-example/README.md +++ b/server-example/README.md @@ -8,18 +8,12 @@ Before running, it is **recommended** to install the versions of packages that w pip install -r requirements.txt ``` -And if you don't have installed flask yet: - -```sh -apt install python3-flask -``` - ### Running -You must inform the environment variable FLASK_APP and then run: +You must set the FLASK_APP environment variable before running the server: ```sh -export FLASK_APP=hello.py +export FLASK_APP=app.py flask run ``` From 66ee9e04bc6f84f2ebf20f8326e636b8a2f89776 Mon Sep 17 00:00:00 2001 From: AlexeyDer Date: Sat, 25 Apr 2020 00:20:33 +0700 Subject: [PATCH 8/9] Deleted unnecessary dependencies --- server-example/requirements.txt | 39 +-------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/server-example/requirements.txt b/server-example/requirements.txt index f8451e3..ddd1daf 100644 --- a/server-example/requirements.txt +++ b/server-example/requirements.txt @@ -1,38 +1 @@ -appdirs==1.4.3 -asn1crypto==0.24.0 -click==7.1.1 -configparser==4.0.2 -contextlib2==0.6.0.post1 -cryptography==2.1.4 -distlib==0.3.0 -enum34==1.1.6 -filelock==3.0.12 -Flask==1.1.2 -idna==2.6 -importlib-metadata==1.6.0 -importlib-resources==1.4.0 -ipaddress==1.0.17 -itsdangerous==1.1.0 -Jinja2==2.11.2 -keyring==10.6.0 -keyrings.alt==3.0 -MarkupSafe==1.1.1 -mysql-connector-python==2.1.6 -mysql-utilities==1.6.4 -paramiko==2.0.0 -pathlib2==2.3.5 -pexpect==4.2.1 -pyasn1==0.4.2 -pycrypto==2.6.1 -pygobject==3.26.1 -pyodbc==4.0.17 -pysqlite==2.7.0 -pyxdg==0.25 -scandir==1.10.0 -SecretStorage==2.3.1 -singledispatch==3.4.0.3 -six==1.14.0 -typing==3.7.4.1 -virtualenv==20.0.18 -Werkzeug==1.0.1 -zipp==1.2.0 +Flask>1.1 From 9a98b7e69613b4e58d663c3f64dd5dc306651cef Mon Sep 17 00:00:00 2001 From: AlexeyDer Date: Sat, 25 Apr 2020 00:22:57 +0700 Subject: [PATCH 9/9] Corrected description --- server-example/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server-example/app.py b/server-example/app.py index d4789a9..70acd42 100644 --- a/server-example/app.py +++ b/server-example/app.py @@ -1,4 +1,4 @@ -# Copyright 2018 The pybadge Authors +# Copyright 2020 The pybadge Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Example CI server that serves badges """ +""" Example CI server that serves badges.""" from flask import Flask import pybadges