chatgpt/data-arbiter-todo

26 lines
521 B
Plaintext
Raw Normal View History

2022-12-17 22:39:21 +02:00
from flask import Flask
import sqlite3
app = Flask(__name__)
# Create a route for the web server
@app.route('/')
def serve_data():
# Connect to the database
db = sqlite3.connect("btc_timeseries.db")
# Fetch the data from the database
cursor = db.execute("SELECT * FROM timeseries")
data = cursor.fetchall()
# Convert the data to JSON format
data_json = json.dumps(data)
# Return the data as a response to the request
return data_json
if __name__ == '__main__':
# Run the web server
app.run()