-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
40 lines (32 loc) · 1.03 KB
/
server.py
File metadata and controls
40 lines (32 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from flask import Flask, jsonify, send_from_directory, render_template, make_response
import os
import json
import webbrowser
app = Flask(__name__)
# Serve index.html from the 'templates' folder
@app.route('/')
def index():
return render_template('index.html')
# Serve static files from the 'static' folder
@app.route('/static/<path:filename>')
def serve_static(filename):
response = make_response(send_from_directory('static', filename))
if filename.endswith('.mjs'):
response.headers['Content-Type'] = 'application/javascript; charset=utf-8; module'
return response
# API endpoint to get the list of files
@app.route('/get_files')
def get_files():
folder_path = './static/js/filters'
files = os.listdir(folder_path)
print(files)
return jsonify(files)
@app.route('/get_config')
def get_config():
path = "./config.json"
with open(path, 'r') as file:
data = json.load(file)
return data
if __name__ == '__main__':
webbrowser.open("http://127.0.0.1:5000/")
app.run(port=5000)