Varsha Dewangan commited on
Commit
9abcdcf
·
1 Parent(s): ee87a8b

test files added

Browse files
Files changed (6) hide show
  1. .gitattributes +0 -35
  2. README.md +59 -11
  3. app.py +28 -0
  4. dockerfile +12 -0
  5. requirements.txt +2 -0
  6. templates/index.html +114 -0
.gitattributes DELETED
@@ -1,35 +0,0 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -1,11 +1,59 @@
1
- ---
2
- title: Test
3
- emoji: 👀
4
- colorFrom: pink
5
- colorTo: blue
6
- sdk: docker
7
- pinned: false
8
- license: other
9
- ---
10
-
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Flask Test App for Hugging Face Spaces
2
+
3
+ A simple Flask web application designed for testing deployment on Hugging Face Spaces.
4
+
5
+ ## Features
6
+
7
+ - Simple web interface with greeting functionality
8
+ - REST API endpoint for testing
9
+ - Health check endpoint
10
+ - Responsive design
11
+ - Ready for Hugging Face Spaces deployment
12
+
13
+ ## Project Structure
14
+
15
+ ```
16
+ flask-test-app/
17
+ ├── app.py # Main Flask application
18
+ ├── requirements.txt # Python dependencies
19
+ ├── Dockerfile # Docker configuration
20
+ ├── README.md # This file
21
+ └── templates/
22
+ └── index.html # HTML template
23
+ ```
24
+
25
+ ## Local Development
26
+
27
+ 1. Install dependencies:
28
+ ```bash
29
+ pip install -r requirements.txt
30
+ ```
31
+
32
+ 2. Run the application:
33
+ ```bash
34
+ python app.py
35
+ ```
36
+
37
+ 3. Open your browser and navigate to `http://localhost:7860`
38
+
39
+ ## API Endpoints
40
+
41
+ - `GET /` - Main web interface
42
+ - `POST /api/greet` - Greeting API endpoint
43
+ - `GET /health` - Health check endpoint
44
+
45
+ ## Deployment on Hugging Face Spaces
46
+
47
+ 1. Create a new Space on Hugging Face
48
+ 2. Choose "Docker" as the SDK
49
+ 3. Upload all the files from this project
50
+ 4. The app will automatically deploy and be accessible via your Space URL
51
+
52
+ ## Testing the Deployment
53
+
54
+ Once deployed, you can test the application by:
55
+ 1. Visiting the main page to see the web interface
56
+ 2. Using the greeting form to test the API
57
+ 3. Checking the health endpoint at `/health`
58
+
59
+ The application runs on port 7860, which is the default port for Hugging Face Spaces.
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, request, jsonify
2
+ import os
3
+
4
+ app = Flask(__name__)
5
+
6
+ @app.route('/')
7
+ def home():
8
+ return render_template('index.html')
9
+
10
+ @app.route('/api/greet', methods=['POST'])
11
+ def greet():
12
+ data = request.get_json()
13
+ name = data.get('name', 'World')
14
+ return jsonify({
15
+ 'message': f'Hello, {name}!',
16
+ 'status': 'success'
17
+ })
18
+
19
+ @app.route('/health')
20
+ def health_check():
21
+ return jsonify({
22
+ 'status': 'healthy',
23
+ 'message': 'Flask app is running successfully!'
24
+ })
25
+
26
+ if __name__ == '__main__':
27
+ port = int(os.environ.get('PORT', 7860))
28
+ app.run(host='0.0.0.0', port=port, debug=False)
dockerfile ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9-slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY requirements.txt .
6
+ RUN pip install -r requirements.txt
7
+
8
+ COPY . .
9
+
10
+ EXPOSE 7860
11
+
12
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ flask==2.3.3
2
+ gunicorn==21.2.0
templates/index.html ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Test App</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ max-width: 800px;
11
+ margin: 0 auto;
12
+ padding: 20px;
13
+ background-color: #f5f5f5;
14
+ }
15
+ .container {
16
+ background-color: white;
17
+ padding: 30px;
18
+ border-radius: 10px;
19
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
20
+ }
21
+ h1 {
22
+ color: #333;
23
+ text-align: center;
24
+ }
25
+ .form-group {
26
+ margin-bottom: 20px;
27
+ }
28
+ label {
29
+ display: block;
30
+ margin-bottom: 5px;
31
+ font-weight: bold;
32
+ }
33
+ input[type="text"] {
34
+ width: 100%;
35
+ padding: 10px;
36
+ border: 1px solid #ddd;
37
+ border-radius: 5px;
38
+ font-size: 16px;
39
+ }
40
+ button {
41
+ background-color: #007bff;
42
+ color: white;
43
+ padding: 10px 20px;
44
+ border: none;
45
+ border-radius: 5px;
46
+ cursor: pointer;
47
+ font-size: 16px;
48
+ }
49
+ button:hover {
50
+ background-color: #0056b3;
51
+ }
52
+ .result {
53
+ margin-top: 20px;
54
+ padding: 15px;
55
+ background-color: #d4edda;
56
+ border: 1px solid #c3e6cb;
57
+ border-radius: 5px;
58
+ display: none;
59
+ }
60
+ .status {
61
+ margin-top: 20px;
62
+ padding: 10px;
63
+ background-color: #e2e3e5;
64
+ border-radius: 5px;
65
+ text-align: center;
66
+ }
67
+ </style>
68
+ </head>
69
+ <body>
70
+ <div class="container">
71
+ <h1>🚀 Flask Test App</h1>
72
+ <p>This is a simple Flask application deployed on Hugging Face Spaces for testing purposes.</p>
73
+
74
+ <div class="form-group">
75
+ <label for="nameInput">Enter your name:</label>
76
+ <input type="text" id="nameInput" placeholder="Your name here..." value="World">
77
+ </div>
78
+
79
+ <button onclick="greetUser()">Say Hello</button>
80
+
81
+ <div id="result" class="result"></div>
82
+
83
+ <div class="status">
84
+ <strong>Status:</strong> Application is running successfully! ✅
85
+ </div>
86
+ </div>
87
+
88
+ <script>
89
+ async function greetUser() {
90
+ const name = document.getElementById('nameInput').value;
91
+ const resultDiv = document.getElementById('result');
92
+
93
+ try {
94
+ const response = await fetch('/api/greet', {
95
+ method: 'POST',
96
+ headers: {
97
+ 'Content-Type': 'application/json',
98
+ },
99
+ body: JSON.stringify({ name: name })
100
+ });
101
+
102
+ const data = await response.json();
103
+ resultDiv.innerHTML = `<strong>Response:</strong> ${data.message}`;
104
+ resultDiv.style.display = 'block';
105
+ } catch (error) {
106
+ resultDiv.innerHTML = `<strong>Error:</strong> ${error.message}`;
107
+ resultDiv.style.display = 'block';
108
+ resultDiv.style.backgroundColor = '#f8d7da';
109
+ resultDiv.style.borderColor = '#f5c6cb';
110
+ }
111
+ }
112
+ </script>
113
+ </body>
114
+ </html>