Skip to content

Commit

Permalink
Implemented common API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Chelsea486MHz committed Jan 4, 2024
1 parent 7b6d952 commit 5e54166
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 20 deletions.
4 changes: 4 additions & 0 deletions auth/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ ENV PATH="/opt/venv/bin:$PATH"
COPY app.py .
COPY gunicorn_config.py .

# App information
ENV STARGAZER_VERSION=0.0.1
ENV STARGAZER_TYPE=auth

# Run the app
CMD ["gunicorn", "-c", "gunicorn_config.py", "app:app"]
4 changes: 2 additions & 2 deletions auth/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ def api_common_version():
with app.app_context():
if not authenticate(request):
return jsonify({'error': True}), 401
return jsonify({'version': os.environ.get('VERSION')}), 200
return jsonify({'version': os.environ.get('STARGAZER_VERSION')}), 200


@app.route('/api/common/type', methods=['POST'])
def api_common_type():
with app.app_context():
if not authenticate(request):
return jsonify({'error': True}), 401
return jsonify({'version': os.environ.get('TYPE')}), 200
return jsonify({'version': os.environ.get('STARGAZER_TYPE')}), 200


@app.route('/api/token/create', methods=['POST'])
Expand Down
4 changes: 4 additions & 0 deletions compute/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ ENV PATH="/opt/venv/bin:$PATH"
COPY app.py .
COPY gunicorn_config.py .

# App information
ENV STARGAZER_VERSION=0.0.1
ENV STARGAZER_TYPE=compute

# Run the app
CMD ["gunicorn", "-c", "gunicorn_config.py", "app:app"]
18 changes: 9 additions & 9 deletions compute/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Flask, request
from flask import Flask, request, jsonify
import requests
import os

Expand Down Expand Up @@ -43,18 +43,18 @@ def authenticate(request, type='any'):

@app.route('/api/common/version', methods=['POST'])
def api_common_version():
if not authenticate(request, 'any'):
return 'Unauthorized', 401
else:
return response
with app.app_context():
if not authenticate(request):
return jsonify({'error': True}), 401
return jsonify({'version': os.environ.get('STARGAZER_VERSION')}), 200


@app.route('/api/common/type', methods=['POST'])
def api_common_type():
if not authenticate(request, 'any'):
return 'Unauthorized', 401
else:
return response
with app.app_context():
if not authenticate(request):
return jsonify({'error': True}), 401
return jsonify({'version': os.environ.get('STARGAZER_TYPE')}), 200


@app.route('/api/compute/update', methods=['POST'])
Expand Down
4 changes: 4 additions & 0 deletions manager/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ ENV PATH="/opt/venv/bin:$PATH"
COPY app.py .
COPY gunicorn_config.py .

# App information
ENV STARGAZER_VERSION=0.0.1
ENV STARGAZER_TYPE=manager

# Run the app
CMD ["gunicorn", "-c", "gunicorn_config.py", "app:app"]
18 changes: 9 additions & 9 deletions manager/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Flask, request
from flask import Flask, request, jsonify
import requests
import os

Expand Down Expand Up @@ -44,18 +44,18 @@ def authenticate(request, type='any'):

@app.route('/api/common/version', methods=['POST'])
def api_common_version():
if not authenticate(request):
return 'Unauthorized', 401
else:
return response
with app.app_context():
if not authenticate(request):
return jsonify({'error': True}), 401
return jsonify({'version': os.environ.get('STARGAZER_VERSION')}), 200


@app.route('/api/common/type', methods=['POST'])
def api_common_type():
if not authenticate(request):
return 'Unauthorized', 401
else:
return response
with app.app_context():
if not authenticate(request):
return jsonify({'error': True}), 401
return jsonify({'version': os.environ.get('STARGAZER_TYPE')}), 200


@app.route('/api/manager/register', methods=['POST'])
Expand Down

0 comments on commit 5e54166

Please sign in to comment.