diff --git a/README.md b/README.md index f8dbf34..4e8f037 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ shows what is done and not done makes it easy to check periodically. # How? -This tiny Flask API runs on a server (Raspberry Pi, etc.). It has very basic authentication +This tiny Python 3 Flask API runs on a server (Raspberry Pi, etc.). It has very basic authentication and waits for a curl (or similar) GET request with some small amount of data. The data are displayed on a simple web page. @@ -16,6 +16,10 @@ whatever data you pass. You can either run with the internal Flask development server or something like gunicorn. +I am experimenting with virtualenv, for which I am following the instructions at +https://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask (this +is also the place from I cribbed the basic application functions). + # Other Use Cases? I'm sure there are some. diff --git a/app.py b/app.py index a3edb7a..2c8dabb 100644 --- a/app.py +++ b/app.py @@ -27,7 +27,7 @@ def get_password(username): def unauthorized(): return make_response(jsonify({'error': 'Unauthorized access'}), 403) -@app.route('/new', methods=['POST', 'GET']) +@app.route('/log/new', methods=['POST', 'GET']) @auth.login_required def create_status(): # At least try to clean up user-submitted data @@ -52,11 +52,11 @@ def create_status(): return jsonify({'status': status}), 201 -@app.route('/raw', methods=['GET']) +@app.route('/log/raw', methods=['GET']) def get_statuses_raw(): return jsonify({'statuses': statuses[::-1]}) -@app.route('/', methods=['GET']) +@app.route('/log', methods=['GET']) def get_statuses(): long_agos = [humanfriendly.format_timespan(datetime.datetime.now().timestamp() - status['timestamp']) for status in statuses[::-1]] return render_template("index.html",