21 lines
664 B
Python

from flask import Flask, jsonify
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import os
app = Flask(__name__)
@app.route("/market", methods=["GET"])
def get_market():
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name("credentials.json", scope)
client = gspread.authorize(creds)
sheet = client.open("1eGzEq6V-eLFPTtpkhSjq7dOSz48aw4Vzi1PyBw1Awmk").sheet1
data = sheet.get_all_records()
return jsonify(data)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 8080)))