sw-jobs-api/api/api.py
ChrQR 4768f750e3
All checks were successful
Build and Push Docker Images / build (push) Successful in 35s
debug false
2024-05-30 01:20:54 +02:00

24 lines
590 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(debug=False, host='0.0.0.0')