sw-jobs-api/api/api.py
ChrQR 96e42454b1
All checks were successful
Build and Push Docker Images / build (push) Successful in 37s
api dockerfile
2024-06-01 17:16:31 +02:00

24 lines
588 B
Python

from flask import Flask, jsonify
import json
import os
app = Flask(__name__)
# Path to your JSON file for production
db_file = os.path.join('scrapers', 'jobs_db.json')
# Path to db JSON file for development
#db_file = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'scrapers', 'jobs_db.json')
@app.route('/jobs', methods=['GET'])
def get_jobs():
if os.path.exists(db_file):
with open(db_file, 'r') as file:
jobs = json.load(file)
else:
jobs = []
return jsonify(jobs)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)