chatgpt/letters/openGPT-python-threads.py

23 lines
452 B
Python
Raw Normal View History

2022-12-17 22:39:21 +02:00
from threading import Thread
from flask import Flask
app = Flask(__name__)
@app.route('/api')
def api():
# API logic here
return 'API response'
def data_request_task():
# Data requesting logic here
print('Data request task finished')
if __name__ == '__main__':
# Start the Flask API in a separate thread
api_thread = Thread(target=app.run)
api_thread.start()
# Run the data requesting task
data_request_task()