2024-05-29 21:28:58 +00:00
|
|
|
from flask import Flask, jsonify
|
|
|
|
import json
|
|
|
|
import os
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
2024-05-29 21:48:58 +00:00
|
|
|
# Path to your JSON file for production
|
2024-05-29 21:28:58 +00:00
|
|
|
db_file = os.path.join('scrapers', 'jobs_db.json')
|
|
|
|
|
2024-05-29 21:48:58 +00:00
|
|
|
# Path to db JSON file for development
|
|
|
|
#db_file = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'scrapers', 'jobs_db.json')
|
|
|
|
|
2024-05-29 22:26:09 +00:00
|
|
|
@app.route('/jobs', methods=['GET'])
|
2024-05-29 21:28:58 +00:00
|
|
|
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__':
|
2024-05-29 21:48:58 +00:00
|
|
|
app.run(debug=True, host='0.0.0.0')
|