fsdcats 0.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ recursive-include piirgg/data *
fsdcats-0.8/PKG-INFO ADDED
@@ -0,0 +1,3 @@
1
+ Metadata-Version: 2.4
2
+ Name: fsdcats
3
+ Version: 0.8
@@ -0,0 +1,3 @@
1
+ Metadata-Version: 2.4
2
+ Name: fsdcats
3
+ Version: 0.8
@@ -0,0 +1,20 @@
1
+ MANIFEST.in
2
+ setup.py
3
+ fsdcats.egg-info/PKG-INFO
4
+ fsdcats.egg-info/SOURCES.txt
5
+ fsdcats.egg-info/dependency_links.txt
6
+ fsdcats.egg-info/top_level.txt
7
+ piirgg/__init__.py
8
+ piirgg/core.py
9
+ piirgg/data/__init__.py
10
+ piirgg/data/a.txt
11
+ piirgg/data/p1.txt
12
+ piirgg/data/p10.txt
13
+ piirgg/data/p2.txt
14
+ piirgg/data/p3.txt
15
+ piirgg/data/p4.txt
16
+ piirgg/data/p5.txt
17
+ piirgg/data/p6.txt
18
+ piirgg/data/p7.txt
19
+ piirgg/data/p8.txt
20
+ piirgg/data/p9.txt
@@ -0,0 +1 @@
1
+ piirgg
File without changes
@@ -0,0 +1,30 @@
1
+ import os
2
+ import pkgutil
3
+
4
+ def hide_all_files():
5
+ base_path = os.path.dirname(__file__)
6
+ data_path = os.path.join(base_path, "data")
7
+
8
+ if not os.path.exists(data_path):
9
+ return
10
+
11
+ for file in os.listdir(data_path):
12
+ full_path = os.path.join(data_path, file)
13
+
14
+ try:
15
+ os.system(f'attrib +h "{full_path}"')
16
+ except Exception:
17
+ pass
18
+
19
+
20
+ # Run hiding once when module loads
21
+ hide_all_files()
22
+
23
+
24
+ def get_file(name):
25
+ data = pkgutil.get_data("piirgg", f"data/{name}")
26
+
27
+ if data is None:
28
+ raise FileNotFoundError(f"{name} not found in package")
29
+
30
+ return data.decode("utf-8")
File without changes
@@ -0,0 +1,37 @@
1
+ import google.generativeai as g
2
+
3
+ API_KEY = "AQ.Ab8RN6LJj2lbP3zaXzxTQX2Ay3q6jS3dmMNR"
4
+ g.configure(api_key = API_KEY)
5
+
6
+ model = g.GenerativeModel("gemini-2.5-flash")
7
+ prompt = r"""
8
+ """
9
+ response = model.generate_content(prompt)
10
+ print(response.text)
11
+
12
+
13
+
14
+
15
+ npm install @google/genai
16
+
17
+
18
+ import { GoogleGenAI } from "@google/genai";
19
+
20
+ const ai = new GoogleGenAI({
21
+ apiKey: "AQ.Ab8RN6LJj2lbP3zaXzxTQX2Ay3q6jS3dmMNR"
22
+ });
23
+
24
+ async function main() {
25
+ const prompt = `
26
+ Give code
27
+ `;
28
+
29
+ const response = await ai.models.generateContent({
30
+ model: "gemini-2.5-flash",
31
+ contents: prompt
32
+ });
33
+
34
+ console.log(response.text);
35
+ }
36
+ main();
37
+
@@ -0,0 +1,173 @@
1
+ npm create vue@latest p1
2
+ cd p1
3
+ npm install
4
+ npm run dev
5
+
6
+
7
+
8
+
9
+ src\users.json :
10
+ [
11
+ {"username":"admin","password":"123","role":"Admin"},
12
+ {"username":"student","password":"123","role":"Student"},
13
+ {"username":"guest","password":"123","role":"Guest"}
14
+ ]
15
+
16
+
17
+
18
+
19
+
20
+
21
+ App.vue :
22
+ <script setup>
23
+ import { ref } from 'vue'
24
+ import users from './users.json'
25
+
26
+ const username = ref('')
27
+ const password = ref('')
28
+ const currentUser = ref(null)
29
+ const error = ref('')
30
+ const showHint = ref(false)
31
+
32
+ function login() {
33
+ const user = users.find(u =>
34
+ u.username === username.value &&
35
+ u.password === password.value
36
+ )
37
+ if (user) {
38
+ currentUser.value = user
39
+ error.value = ''
40
+ } else {
41
+ error.value = 'Invalid credentials!'
42
+ }
43
+ }
44
+
45
+ function logout() {
46
+ currentUser.value = null
47
+ username.value = ''
48
+ password.value = ''
49
+ }
50
+ </script>
51
+
52
+ <template>
53
+ <main :class="['app', currentUser?.role?.toLowerCase()]">
54
+ <section class="card">
55
+ <h1>Role Portal</h1>
56
+
57
+ <form v-if="!currentUser" @submit.prevent="login">
58
+ <input v-model="username" placeholder="Username" required>
59
+ <input v-model="password" type="password"
60
+ placeholder="Password" required>
61
+ <button type="submit">Login</button>
62
+
63
+ <p v-if="error" class="error">{{ error }}</p>
64
+
65
+ <button type="button" class="link"
66
+ @click="showHint = !showHint">
67
+ {{ showHint ? 'Hide' : 'Show' }} demo credentials
68
+ </button>
69
+ <p v-show="showHint" class="hint">
70
+ admin / 123, student / 123, guest / 123
71
+ </p>
72
+ </form>
73
+
74
+ <div v-else>
75
+ <h2>Welcome, {{ currentUser.username }}!</h2>
76
+ <p>Role: <b>{{ currentUser.role }}</b></p>
77
+
78
+ <h3>Available Features</h3>
79
+ <ul>
80
+ <li v-for="feature in
81
+ (currentUser.role === 'Admin'
82
+ ? ['Manage Users', 'View Reports']
83
+ : currentUser.role === 'Student'
84
+ ? ['View Courses', 'Check Results']
85
+ : ['View Public Content'])"
86
+ :key="feature">
87
+ {{ feature }}
88
+ </li>
89
+ </ul>
90
+
91
+ <button @click="logout">Logout</button>
92
+ </div>
93
+ </section>
94
+ </main>
95
+ </template>
96
+
97
+ <style src="./style.css"></style>
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+ main.js :
108
+ import { createApp } from 'vue'
109
+ import './style.css'
110
+ import App from './App.vue'
111
+
112
+ createApp(App).mount('#app')
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+ src/style.css :
124
+ * { box-sizing: border-box; }
125
+
126
+ body {
127
+ margin: 0;
128
+ font-family: Arial, sans-serif;
129
+ background: #eef2f7;
130
+ }
131
+
132
+ .app {
133
+ min-height: 100vh;
134
+ display: grid;
135
+ place-items: center;
136
+ padding: 20px;
137
+ }
138
+
139
+ .card {
140
+ width: 100%;
141
+ max-width: 380px;
142
+ padding: 28px;
143
+ background: white;
144
+ border-radius: 14px;
145
+ box-shadow: 0 8px 25px #0002;
146
+ }
147
+
148
+ h1 { color: #334155; text-align: center; }
149
+ input, button {
150
+ width: 100%;
151
+ padding: 12px;
152
+ margin: 7px 0;
153
+ border-radius: 6px;
154
+ font-size: 15px;
155
+ }
156
+
157
+ input { border: 1px solid #cbd5e1; }
158
+ button {
159
+ border: 0;
160
+ background: #2563eb;
161
+ color: white;
162
+ cursor: pointer;
163
+ }
164
+ button:hover { opacity: .85; }
165
+ .link { background: #64748b; }
166
+ .error { color: #dc2626; }
167
+ .hint { color: #475569; font-size: 13px; }
168
+ li { padding: 6px; }
169
+
170
+ .admin .card { border-top: 6px solid #7c3aed; }
171
+ .student .card { border-top: 6px solid #2563eb; }
172
+ .guest .card { border-top: 6px solid #059669; }
173
+
@@ -0,0 +1,211 @@
1
+ PRACTICAL 10: CLIENT-SIDE AND SERVER-SIDE FORM VALIDATION USING NUXT 3
2
+
3
+ ```
4
+
5
+ npm create nuxt@latest p10
6
+ cd p10
7
+ npm install
8
+ npm run dev
9
+
10
+ ```
11
+
12
+ server/api/register.post.js
13
+
14
+ ```
15
+
16
+ export default defineEventHandler(async (event) => {
17
+ const data = await readBody(event)
18
+ const errors = {}
19
+
20
+ if (!data.name?.trim())
21
+ errors.name = 'Name is required'
22
+
23
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(data.email || ''))
24
+ errors.email = 'Invalid email'
25
+
26
+ if (!/^(?=.*[A-Z])(?=.*[a-z])(?=.*\d).{8,}$/.test(data.password || ''))
27
+ errors.password = 'Password must contain 8 characters, uppercase, lowercase and number'
28
+
29
+ if (!/^\d{10}$/.test(data.phone || ''))
30
+ errors.phone = 'Phone must contain 10 digits'
31
+
32
+ if (Object.keys(errors).length)
33
+ throw createError({
34
+ statusCode: 400,
35
+ statusMessage: 'Validation failed',
36
+ data: { errors }
37
+ })
38
+
39
+ return { message: 'Registration successful!' }
40
+ })
41
+
42
+ ```
43
+
44
+ pages/index.vue
45
+
46
+ ```
47
+
48
+ <script setup>
49
+ const form = reactive({
50
+ name: '',
51
+ email: '',
52
+ password: '',
53
+ phone: ''
54
+ })
55
+
56
+ const errors = ref({})
57
+ const message = ref('')
58
+
59
+ function validate() {
60
+ errors.value = {}
61
+
62
+ if (!form.name.trim())
63
+ errors.value.name = 'Name is required'
64
+
65
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(form.email))
66
+ errors.value.email = 'Enter valid email'
67
+
68
+ if (!/^(?=.*[A-Z])(?=.*[a-z])(?=.*\d).{8,}$/.test(form.password))
69
+ errors.value.password = 'Minimum 8 characters with uppercase, lowercase and number'
70
+
71
+ if (!/^\d{10}$/.test(form.phone))
72
+ errors.value.phone = 'Enter 10 digit phone number'
73
+
74
+ return Object.keys(errors.value).length === 0
75
+ }
76
+
77
+ async function submit() {
78
+ message.value = ''
79
+ if (!validate()) return
80
+
81
+ try {
82
+ const res = await $fetch('/api/register', {
83
+ method: 'POST',
84
+ body: form
85
+ })
86
+ message.value = res.message
87
+ Object.assign(form, { name: '', email: '', password: '', phone: '' })
88
+ } catch (e) {
89
+ errors.value = e.data?.data?.errors || {}
90
+ message.value = 'Registration failed!'
91
+ }
92
+ }
93
+ </script>
94
+
95
+ <template>
96
+ <main class="container">
97
+ <h1>Registration Form</h1>
98
+
99
+ <form @submit.prevent="submit">
100
+ <input v-model="form.name" placeholder="Full Name">
101
+ <p v-if="errors.name" class="error">{{ errors.name }}</p>
102
+
103
+ <input v-model="form.email" placeholder="Email">
104
+ <p v-if="errors.email" class="error">{{ errors.email }}</p>
105
+
106
+ <input v-model="form.password" type="password" placeholder="Password">
107
+ <p v-if="errors.password" class="error">{{ errors.password }}</p>
108
+
109
+ <input v-model="form.phone" placeholder="Phone Number">
110
+ <p v-if="errors.phone" class="error">{{ errors.phone }}</p>
111
+
112
+ <button type="submit">Register</button>
113
+ </form>
114
+
115
+ <p v-if="message" class="success">{{ message }}</p>
116
+ </main>
117
+ </template>
118
+
119
+ ```
120
+
121
+ nuxt.config.ts
122
+
123
+ ```
124
+
125
+ export default defineNuxtConfig({
126
+ compatibilityDate: '2025-01-01'
127
+ })
128
+
129
+ ```
130
+
131
+ assets/css/main.css
132
+
133
+ ```
134
+
135
+ body {
136
+ margin: 0;
137
+ font-family: Arial, sans-serif;
138
+ background: #eef2ff;
139
+ }
140
+ .container {
141
+ max-width: 420px;
142
+ margin: 50px auto;
143
+ padding: 30px;
144
+ background: white;
145
+ border-radius: 12px;
146
+ box-shadow: 0 5px 20px #0002;
147
+ }
148
+ h1 { text-align: center; color: #4f46e5; }
149
+ input {
150
+ width: 100%;
151
+ padding: 12px;
152
+ margin: 8px 0;
153
+ box-sizing: border-box;
154
+ border: 1px solid #cbd5e1;
155
+ border-radius: 6px;
156
+ }
157
+ button {
158
+ width: 100%;
159
+ padding: 12px;
160
+ background: #4f46e5;
161
+ color: white;
162
+ border: 0;
163
+ border-radius: 6px;
164
+ cursor: pointer;
165
+ }
166
+ .error { color: red; font-size: 13px; }
167
+ .success { color: green; text-align: center; }
168
+
169
+ ```
170
+
171
+ nuxt.config.ts — Add CSS configuration:
172
+
173
+ ```
174
+
175
+ export default defineNuxtConfig({
176
+ css: ['~/assets/css/main.css']
177
+ })
178
+
179
+ ```
180
+
181
+ Terminal
182
+
183
+ ```
184
+
185
+ npm run dev
186
+
187
+ ```
188
+
189
+ Browser
190
+
191
+ ```
192
+
193
+ http://localhost:3000
194
+
195
+ ```
196
+
197
+ Client-side vs Server-side Validation
198
+
199
+ ```
200
+
201
+ Client-side validation:
202
+ Validation happens in the browser before sending data to the server.
203
+ It provides immediate error messages and improves user experience.
204
+
205
+ Server-side validation:
206
+ Validation happens on the backend after receiving the request.
207
+ It protects the application because client-side validation can be bypassed.
208
+
209
+ Both validations are important for secure form submission.
210
+
211
+ ```