cosimotaiuti commited on
Commit
08ade65
·
verified ·
1 Parent(s): 00bc02c

Upload 6 files

Browse files
Files changed (6) hide show
  1. DOCKER +0 -0
  2. Dockerfile +24 -0
  3. LICENSE +21 -0
  4. README.md +20 -8
  5. app.py +58 -0
  6. requirements.txt +4 -0
DOCKER ADDED
File without changes
Dockerfile ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use official Python runtime as base image
2
+ FROM python:3.9-slim
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Copy requirements first to leverage Docker cache
8
+ COPY requirements.txt .
9
+
10
+ # Install dependencies
11
+ RUN pip install -r requirements.txt
12
+
13
+ # Copy the rest of the application
14
+ COPY . .
15
+
16
+ # Set environment variables
17
+ ENV PYTHONUNBUFFERED=1
18
+ ENV PORT=7860
19
+
20
+ # Expose the port the app runs on
21
+ EXPOSE 7860
22
+
23
+ # Command to run the application
24
+ CMD ["python", "app.py"]
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Johnny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,12 +1,24 @@
1
  ---
2
- title: Team9
3
- emoji: 🐨
4
- colorFrom: indigo
5
- colorTo: yellow
6
- sdk: docker
 
 
7
  pinned: false
8
- license: apache-2.0
9
- short_description: team9 test
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: The Last Message
3
+ emoji: 📱
4
+ colorFrom: gray
5
+ colorTo: red
6
+ sdk: gradio
7
+ sdk_version: "3.50.2"
8
+ app_file: app.py
9
  pinned: false
 
 
10
  ---
11
 
12
+ # The Last Message - Horror Escape Game
13
+
14
+ An interactive horror escape game where your messages determine the fate of others.
15
+
16
+ ### Docker
17
+
18
+ # Build the image
19
+
20
+ docker build -t p5js-game .
21
+
22
+ # Run the container
23
+
24
+ docker run -p 8000:8000 p5js-game
app.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify, render_template, send_from_directory
2
+ import requests
3
+ import os
4
+ from flask_cors import CORS
5
+ import logging
6
+
7
+ app = Flask(__name__)
8
+ CORS(app) # Enable CORS for development
9
+
10
+ # Set up logging
11
+ logging.basicConfig(level=logging.INFO)
12
+ logger = logging.getLogger(__name__)
13
+
14
+ @app.route('/mistral-proxy', methods=['POST'])
15
+ def proxy_to_mistral():
16
+ MISTRAL_API_KEY = os.getenv('MISTRAL_API_KEY')
17
+ MISTRAL_API_URL = "https://api.mistral.ai/v1/chat/completions"
18
+
19
+ if not MISTRAL_API_KEY:
20
+ logger.error("MISTRAL_API_KEY not configured")
21
+ return jsonify({"error": "MISTRAL_API_KEY not configured"}), 500
22
+
23
+ headers = {
24
+ 'Authorization': f'Bearer {MISTRAL_API_KEY}',
25
+ 'Content-Type': 'application/json'
26
+ }
27
+
28
+ try:
29
+ # Log incoming request (excluding sensitive data)
30
+ logger.info(f"Received request for Mistral API")
31
+
32
+ response = requests.post(MISTRAL_API_URL,
33
+ headers=headers,
34
+ json=request.json)
35
+
36
+ # Check if the response was successful
37
+ response.raise_for_status()
38
+
39
+ return jsonify(response.json())
40
+ except requests.exceptions.RequestException as e:
41
+ logger.error(f"Error calling Mistral API: {str(e)}")
42
+ return jsonify({"error": f"Error calling Mistral API: {str(e)}"}), 500
43
+ except Exception as e:
44
+ logger.error(f"Unexpected error: {str(e)}")
45
+ return jsonify({"error": str(e)}), 500
46
+
47
+ # Serve static files
48
+ @app.route('/')
49
+ def index():
50
+ return send_from_directory('static', 'index.html')
51
+
52
+ # Add this if you want to serve other static files
53
+ @app.route('/<path:path>')
54
+ def serve_static(path):
55
+ return send_from_directory('static', path)
56
+
57
+ if __name__ == '__main__':
58
+ app.run(host='0.0.0.0', port=7860)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ flask==3.0.0
2
+ requests==2.31.0
3
+ flask-cors==4.0.0
4
+ python-dotenv==1.0.0