-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
34 lines (27 loc) · 1.34 KB
/
app.py
File metadata and controls
34 lines (27 loc) · 1.34 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
import logging
import os
from flask import Flask, render_template, send_from_directory
# Get the current directory of the script
current_directory = os.path.dirname(os.path.abspath(__file__))
# Create the Flask app
app = Flask(__name__,
static_folder=os.path.join(current_directory, 'scratch-gui/build/static'), # Relative static folder path
template_folder=os.path.join(current_directory, 'scratch-gui/build')) # Relative template folder path
# Suppress Flask's default logging
log = logging.getLogger('werkzeug') # This is the default logger for Flask
log.setLevel(logging.ERROR) # Set to ERROR to suppress INFO and DEBUG messages
@app.route('/')
def index():
# Serve the index.html from the new path
return render_template('index.html')
@app.route('/static/<path:filename>')
def static_files(filename):
# Serve static files from the relative static directory
return send_from_directory(os.path.join(current_directory, 'scratch-gui/build/static'), filename)
@app.route('/<path:filename>')
def serve_build_files(filename):
# Serve other files from the build directory
return send_from_directory(os.path.join(current_directory, 'scratch-gui/build'), filename)
if __name__ == '__main__':
# Run the Flask application without extra logging
app.run(debug=False) # Set debug=False to disable debug output