diff --git a/server-example/README.md b/server-example/README.md new file mode 100644 index 0000000..6ec7b4c --- /dev/null +++ b/server-example/README.md @@ -0,0 +1,20 @@ +## 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 +``` + +### Running + +You must set the FLASK_APP environment variable before running the server: + +```sh +export FLASK_APP=app.py +flask run +``` + + * Running on http://127.0.0.1:5000/ \ No newline at end of file diff --git a/server-example/app.py b/server-example/app.py new file mode 100644 index 0000000..70acd42 --- /dev/null +++ b/server-example/app.py @@ -0,0 +1,37 @@ +# 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. +# 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 +import flask + +app = Flask(__name__) + + +@app.route('/') +def serveBadges(): + badge = pybadges.badge( + left_text='build', + right_text='passing', + right_color='#008000') + + response = flask.make_response(badge) + response.content_type = 'image/svg+xml' + return response + + +if __name__ == '__main__': + app.run() diff --git a/server-example/requirements.txt b/server-example/requirements.txt new file mode 100644 index 0000000..ddd1daf --- /dev/null +++ b/server-example/requirements.txt @@ -0,0 +1 @@ +Flask>1.1