23 lines
452 B
Python
23 lines
452 B
Python
|
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()
|
||
|
|