-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexampleAIResponse.txt
More file actions
239 lines (199 loc) · 5.6 KB
/
exampleAIResponse.txt
File metadata and controls
239 lines (199 loc) · 5.6 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
---------Chat Reponse-----------Here's a simple Flask-based web application that allows you to store and manage employee information. Below is the file structure, the content of each file including `main.py`, and the `README.md`.
### File Structure
```
employee_manager/
│
├── main.py
├── templates/
│ ├── index.html
│ ├── add_employee.html
│ └── employee_list.html
├── static/
│ └── styles.css
└── README.md
```
### main.py
```python
from flask import Flask, render_template, request, redirect, url_for, flash
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///employees.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.secret_key = 'your_secret_key'
db = SQLAlchemy(app)
class Employee(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(100), nullable=False)
position = db.Column(db.String(100), nullable=False)
email = db.Column(db.String(100), nullable=False)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/employees')
def employee_list():
employees = Employee.query.all()
return render_template('employee_list.html', employees=employees)
@app.route('/add', methods=['GET', 'POST'])
def add_employee():
if request.method == 'POST':
name = request.form['name']
position = request.form['position']
email = request.form['email']
new_employee = Employee(name=name, position=position, email=email)
db.session.add(new_employee)
db.session.commit()
flash('Employee added successfully!')
return redirect(url_for('employee_list'))
return render_template('add_employee.html')
if __name__ == '__main__':
db.create_all()
app.run(debug=True)
```
### templates/index.html
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
<title>Employee Manager</title>
</head>
<body>
<h1>Welcome to Employee Manager</h1>
<a href="{{ url_for('add_employee') }}">Add Employee</a>
<a href="{{ url_for('employee_list') }}">View Employees</a>
</body>
</html>
```
### templates/add_employee.html
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
<title>Add Employee</title>
</head>
<body>
<h1>Add Employee</h1>
<form action="{{ url_for('add_employee') }}" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br>
<label for="position">Position:</label>
<input type="text" id="position" name="position" required><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br>
<input type="submit" value="Add Employee">
</form>
<br>
<a href="{{ url_for('employee_list') }}">Back to Employee List</a>
</body>
</html>
```
### templates/employee_list.html
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
<title>Employee List</title>
</head>
<body>
<h1>Employee List</h1>
<table>
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Email</th>
</tr>
</thead>
<tbody>
{% for employee in employees %}
<tr>
<td>{{ employee.name }}</td>
<td>{{ employee.position }}</td>
<td>{{ employee.email }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<br>
<a href="{{ url_for('add_employee') }}">Add New Employee</a>
<a href="{{ url_for('index') }}">Home</a>
</body>
</html>
```
### static/styles.css
```css
body {
font-family: Arial, sans-serif;
margin: 20px;
}
h1 {
color: #333;
}
table {
width: 100%;
border-collapse: collapse;
}
table, th, td {
border: 1px solid #ddd;
}
th, td {
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
```
### README.md
```markdown
# Employee Manager
A simple web application to manage employee information using Flask and SQLite.
## File Structure
```
employee_manager/
│
├── main.py
├── templates/
│ ├── index.html
│ ├── add_employee.html
│ └── employee_list.html
├── static/
│ └── styles.css
└── README.md
```
## Requirements
- Python 3.x
- Flask
- Flask-SQLAlchemy
## Installation
1. Clone the repository:
```bash
git clone <repository_url>
cd employee_manager
```
2. Install the required packages:
```bash
pip install Flask Flask-SQLAlchemy
```
## Running the Application
1. Run the application:
```bash
python main.py
```
2. Open a web browser and go to `http://127.0.0.1:5000`.
## Features
- Add employees with name, position, and email.
- View the list of employees.
## License
This project is licensed under the MIT License.
```
This setup gives you a basic application to manage employee information with a simple user interface. You can enhance it by adding more features, such as editing and deleting employees.
-----------End of reponse-----------