sw-jobs-api/api.py
Christian bc67482b24
Some checks failed
Build and Push Docker Images / build (push) Failing after 11s
lots of stuff. It now runs in the cloud yay!
2024-06-07 08:46:20 +00: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)