louiecerv commited on
Commit
c9f4d0a
·
1 Parent(s): 58f0b13

save changes

Browse files
Files changed (5) hide show
  1. Dockerfile +20 -0
  2. app.py +31 -0
  3. requirements.txt +8 -0
  4. space.yaml +2 -0
  5. templates/index.html +36 -0
Dockerfile ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the official Python image as a base image
2
+ FROM python:3.10-slim
3
+
4
+ # Set the working directory inside the container
5
+ WORKDIR /app
6
+
7
+ # Copy the current directory contents into the container at /app
8
+ COPY . /app
9
+
10
+ # Install the dependencies from requirements.txt
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ # Expose the port that Flask runs on
14
+ EXPOSE 5000
15
+
16
+ # Set the environment variable for Flask to run in production
17
+ ENV FLASK_ENV=production
18
+
19
+ # Start the Flask application with gunicorn
20
+ CMD ["gunicorn", "-b", "0.0.0.0:5000", "app:app"]
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, request
2
+ import random
3
+
4
+ app = Flask(__name__)
5
+
6
+ # Dummy AI prompt function
7
+ def ask_ai(prompt):
8
+ responses = [
9
+ "AI response 1 to: " + prompt,
10
+ "AI response 2 to: " + prompt,
11
+ "AI response 3 to: " + prompt
12
+ ]
13
+ return random.choice(responses)
14
+
15
+ @app.route('/', methods=['GET', 'POST'])
16
+ def home():
17
+ ai_response = None
18
+ if request.method == 'POST':
19
+ framework = request.form.get('framework')
20
+ description = request.form.get('description')
21
+
22
+ # Create the prompt (for now, just combine user input)
23
+ prompt = f"Framework: {framework}\nDescription: {description}"
24
+
25
+ # Ask AI (dummy code)
26
+ ai_response = ask_ai(prompt)
27
+
28
+ return render_template('index.html', ai_response=ai_response)
29
+
30
+ if __name__ == '__main__':
31
+ app.run(debug=True)
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ blinker==1.9.0
2
+ click==8.1.8
3
+ colorama==0.4.6
4
+ Flask==3.1.0
5
+ itsdangerous==2.2.0
6
+ Jinja2==3.1.5
7
+ MarkupSafe==3.0.2
8
+ Werkzeug==3.1.3
space.yaml ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ sdk: docker
2
+ app_file: app.py
templates/index.html ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Flask AI App</title>
7
+ </head>
8
+ <body>
9
+ <h1>Choose Framework and Ask AI</h1>
10
+
11
+ <form method="POST">
12
+ <!-- Framework Selection -->
13
+ <label for="framework">Select Framework:</label>
14
+ <select name="framework" id="framework" required>
15
+ <option value="Streamlit">Streamlit</option>
16
+ <option value="Gradio">Gradio</option>
17
+ </select>
18
+
19
+ <br><br>
20
+
21
+ <!-- Description Input -->
22
+ <label for="description">Program Description:</label>
23
+ <textarea name="description" id="description" rows="4" required></textarea>
24
+
25
+ <br><br>
26
+
27
+ <!-- Submit Button -->
28
+ <button type="submit">Ask AI</button>
29
+ </form>
30
+
31
+ {% if ai_response %}
32
+ <h2>AI Response:</h2>
33
+ <p>{{ ai_response }}</p>
34
+ {% endif %}
35
+ </body>
36
+ </html>