drakosfire commited on
Commit
d8b766a
1 Parent(s): 295d95b

built initial Dockerfile and modified app.py to serve from flask app in container

Browse files
Files changed (3) hide show
  1. .dockerignore +30 -0
  2. Dockerfile +20 -0
  3. app.py +16 -6
.dockerignore ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ignore Python bytecode files
2
+ *.pyc
3
+ __pycache__/
4
+
5
+ # Ignore the Dockerfile and .dockerignore themselves (optional)
6
+ Dockerfile
7
+ .dockerignore
8
+
9
+ # Ignore the environment file
10
+ .env
11
+
12
+ # Ignore test files
13
+ Ebony, the Twisted Fairy_files
14
+ galleries
15
+ output
16
+ app copy.py
17
+ block_builder copy.py
18
+ example_templates.py
19
+ morogors_meaty_inventory.py
20
+ morgors_meaty_marvels.py
21
+ old app.py
22
+ process_text.py
23
+ README.md
24
+ sd_generator copy.py
25
+ sd_generator copy 2.py
26
+ store_json_example.py
27
+ storeUI copy.html
28
+ template.html
29
+ template.py
30
+ utilites.py
Dockerfile CHANGED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.10-slim
3
+
4
+ # Set the working directory in the container
5
+ WORKDIR /app
6
+
7
+ # Copy the current directory contents into the container at /app
8
+ COPY . /app
9
+
10
+ # Install any necessary dependencies specified in requirements.txt
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ # Expose port 5000 for the Flask app
14
+ EXPOSE 5000
15
+
16
+ # Define environment variable to ensure Flask runs the correct application
17
+ ENV FLASK_APP=app.py
18
+
19
+ # Command to run the Flask app
20
+ CMD ["flask", "run", "--host=0.0.0.0", "--port=5000"]
app.py CHANGED
@@ -1,11 +1,9 @@
1
  # this imports the code from files and modules
2
- from flask import Flask, request, jsonify
3
  from flask_cors import CORS
4
- import utilities as u
5
  import os
6
  import ctypes
7
  import store_helper as sh
8
- import process_text
9
  import block_builder
10
  import sd_generator as sd
11
 
@@ -15,14 +13,26 @@ M_MMAP_THRESHOLD = -3
15
 
16
  # Set malloc mmap threshold.
17
  libc.mallopt(M_MMAP_THRESHOLD, 2**20)
18
- # Ensure the directory exists
19
-
20
-
21
 
22
  # Initialize the Flask application
23
  app = Flask(__name__)
24
  os.makedirs('static/images', exist_ok=True)
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  CORS(app)# Route to handle the incoming POST request with user description
27
 
28
  @app.route('/process-description', methods=['POST'])
 
1
  # this imports the code from files and modules
2
+ from flask import Flask, request, jsonify, send_from_directory
3
  from flask_cors import CORS
 
4
  import os
5
  import ctypes
6
  import store_helper as sh
 
7
  import block_builder
8
  import sd_generator as sd
9
 
 
13
 
14
  # Set malloc mmap threshold.
15
  libc.mallopt(M_MMAP_THRESHOLD, 2**20)
 
 
 
16
 
17
  # Initialize the Flask application
18
  app = Flask(__name__)
19
  os.makedirs('static/images', exist_ok=True)
20
 
21
+ # Serve files from the 'dependencies' directory
22
+ @app.route('/dependencies/<path:filename>')
23
+ def custom_static(filename):
24
+ return send_from_directory('dependencies', filename)
25
+
26
+ # Serve HTML files from the main directory
27
+ @app.route('/<path:filename>')
28
+ def serve_html(filename):
29
+ return send_from_directory('.', filename)
30
+
31
+ # Default route for index
32
+ @app.route('/')
33
+ def index():
34
+ return send_from_directory('.', 'storeUI.html') # Make sure this points to your main HTML file
35
+
36
  CORS(app)# Route to handle the incoming POST request with user description
37
 
38
  @app.route('/process-description', methods=['POST'])