├── .github └── workflows │ ├── main.yml │ └── main_techwithtim-ms-demo.yml ├── __pycache__ ├── main.cpython-311.pyc └── test.cpython-311-pytest-7.2.2.pyc ├── main.py ├── requirements.txt └── test.py /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Python Test 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - "main" 7 | - "prod" 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | strategy: 13 | matrix: 14 | python-version: ["3.11"] 15 | 16 | steps: 17 | - uses: actions/checkout@v3 18 | - name: Set up Python ${{ matrix.python-version }} 19 | uses: actions/setup-python@v4 20 | with: 21 | python-version: ${{ matrix.python-version }} 22 | - name: Install dependencies 23 | run: | 24 | python -m pip install --upgrade pip 25 | pip install pytest 26 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 27 | - name: Test with pytest 28 | run: | 29 | pytest test.py 30 | -------------------------------------------------------------------------------- /.github/workflows/main_techwithtim-ms-demo.yml: -------------------------------------------------------------------------------- 1 | # Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy 2 | # More GitHub Actions for Azure: https://github.com/Azure/actions 3 | 4 | name: 'Build and deploy Python app to Azure Web App: techwithtim-ms-demo' 5 | 6 | on: 7 | push: 8 | branches: 9 | - prod 10 | workflow_dispatch: 11 | 12 | jobs: 13 | build-and-deploy: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | 19 | - name: Set up Python version 20 | uses: actions/setup-python@v1 21 | with: 22 | python-version: '3.9' 23 | 24 | - name: Build using AppService-Build 25 | uses: azure/appservice-build@v2 26 | with: 27 | platform: python 28 | platform-version: '3.9' 29 | 30 | - name: 'Deploy to Azure Web App' 31 | uses: azure/webapps-deploy@v2 32 | with: 33 | app-name: 'techwithtim-ms-demo' 34 | slot-name: 'production' 35 | publish-profile: ${{ secrets.AzureAppService_PublishProfile_5ef8abcfba044d7dbf01deb528562c99 }} 36 | -------------------------------------------------------------------------------- /__pycache__/main.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Microsoft-Live-Demo/039bd066f0f5e4ffa565ec89bfb6240391bec85d/__pycache__/main.cpython-311.pyc -------------------------------------------------------------------------------- /__pycache__/test.cpython-311-pytest-7.2.2.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Microsoft-Live-Demo/039bd066f0f5e4ffa565ec89bfb6240391bec85d/__pycache__/test.cpython-311-pytest-7.2.2.pyc -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | 3 | app = Flask(__name__) 4 | 5 | # add a comment 6 | @app.route("/") 7 | def hello_world(): 8 | return "Hello, World!" 9 | 10 | if __name__ == "__main__": 11 | app.run() -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Flask 2 | pytest -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | from main import app 2 | 3 | def test_index_route(): 4 | response = app.test_client().get("/") 5 | assert response.status_code == 200 6 | assert response.data.decode('utf-8') == "Hello, World!" --------------------------------------------------------------------------------