diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..09fe774 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,19 @@ +name: Deploy + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: akhileshns/heroku-deploy@v3.12.12 # This is the action + with: + heroku_api_key: ${{secrets.HEROKU_API_KEY}} + heroku_app_name: "feature-hunt-automated" #Must be unique in Heroku + heroku_email: "sharma.rachit882@gmail.com" + appdir: "backend" \ No newline at end of file diff --git a/backend/Procfile b/backend/Procfile new file mode 100644 index 0000000..e9aece8 --- /dev/null +++ b/backend/Procfile @@ -0,0 +1 @@ +web: gunicorn -b :$PORT app:app \ No newline at end of file diff --git a/backend/app.py b/backend/app.py index 92d54e4..efe4c2d 100644 --- a/backend/app.py +++ b/backend/app.py @@ -10,8 +10,13 @@ from products import * from product_controller import * from db_init import db +from ping import * + app.secret_key = "testing" CORS(app) -#if __name__ == "__main__": -# app.run(debug=True, port=environ.get("PORT", 5000) , host='0.0.0.0') +if __name__ == "__main__": + port = int(os.environ.get('PORT', 5000)) + app.run(host='0.0.0.0', port=port, debug=True) + # app.debug = True + # waitress.serve(app, port=environ.get("PORT", 5000)) diff --git a/backend/ping.py b/backend/ping.py new file mode 100644 index 0000000..4036807 --- /dev/null +++ b/backend/ping.py @@ -0,0 +1,6 @@ +from app import app + + +@app.route('/ping', methods=['GET']) +def ping(): + return "Ping Pong" diff --git a/backend/products.py b/backend/products.py index de2bcf6..aa5328e 100644 --- a/backend/products.py +++ b/backend/products.py @@ -9,7 +9,7 @@ import os from sys import stderr -from flask import request, jsonify +from flask import request, jsonify, Response from flask import json from app import app @@ -125,7 +125,7 @@ def features(product_name): return Response(response=json.dumps({"Error": "Please provide connection information"}), status=400, mimetype='application/json') - result = product_records.find_one_and_update({"name": productname}, {"$set": {"features": data}}) + result = product_records.find_one_and_update({"name": product_name}, {"$set": {"features": data}}) elif request.method == 'GET': result = product_records.find({"name": product_name}, {"features": 1}) diff --git a/backend/requirements.txt b/backend/requirements.txt index 472f71a..b433a2d 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -29,4 +29,5 @@ toml==0.10.2 urllib3==1.21.1 Werkzeug==2.0.1 bcrypt==3.2.0 - +waitress==2.0.0 +gunicorn