Uztaisīt, ka Post formā var augšupielādēt vairākus attēlus vienlaicīgi, un atzīmēt ar selection box procesing veidu “Sequential”, “multiprocessing”, “threading” un servera pusē visiem failiem veikt attēlu apstrādi ar opencv bibliotēku, attēlu samazinot 2x un saglabājot un piesaistot post. Izveidot DB structure un model “images_in_post” un jaunos attēlus arī attēlot pie posta (jaunos saglabāt kā JPEG)
https://medium.com/@rviswa00/multi-processing-in-python-to-speed-up-your-data-science-8a810267b07
Python multithreading -> izmanto, ja ir daud failu vai tīkla operācija
Multiprocessing tiek panākts linux ar FORK vai SPAWN operiācijam -> izpētīt kā strādā
salabot enums
Tekstiņus rādīt caur i8n localization (pēc piemēra) ar pot, mo failiem. Uztaisīt, ka var pārslēgt Angļu un Latviešu valodu sistēmai.
xxxxxxxxxx
11from flask_babel import _
Strings paši atrodas POT failā, taču PO un MO uzkompilē no tā!
New language
xxxxxxxxxx
11msginit -l en.UTF-8 -o translations/en/LC_MESSAGES/messages.po -i messages.pot --no-translator
Remove duplicates
xxxxxxxxxx
31msguniq translations/en/LC_MESSAGES/messages.po -o translations/en/LC_MESSAGES/messages.po
2msguniq translations/lv/LC_MESSAGES/messages.po -o translations/lv/LC_MESSAGES/messages.po
3msguniq messages.pot -o messages.pot
Update Existing language
xxxxxxxxxx
21msgmerge -U translations/en/LC_MESSAGES/messages.po messages.pot
2msgmerge -U translations/lv/LC_MESSAGES/messages.po messages.pot
Compile
xxxxxxxxxx
21msgfmt -o translations/en/LC_MESSAGES/messages.mo translations/en/LC_MESSAGES/messages.po
2msgfmt -o translations/lv/LC_MESSAGES/messages.mo translations/lv/LC_MESSAGES/messages.po
Alternative
xxxxxxxxxx
31pybabel extract -F babel.cfg -o messages.pot --input-dirs=C:\Users\xnzza\Desktop\eldigen_new
2pybabel update -i messages.pot -d translations
3pybabel compile -d translations
SCSS nested uztaisīt
Tags pievienošana un un editēšana
Jāuztaisa katram savs URL:
React based Tags saraksts, kur var nodzēt, pievienot tags
React based Tags edit skats
Datu apmaiņa notiek ar Flask kā JSON API
Izdalīt base template ārā no kopējā
Piemērs React komponentei EditPostForm
x651import React, { useState, useEffect } from 'react';
2
3export const EditPostForm = ({ postId }) => {
4const [formData, setFormData] = useState({ title: '', body: '' });
5
6// Fetch the existing post data from the backend
7useEffect(() => {
8fetch(`https://jsonplaceholder.typicode.com/posts/${postId}`)
9.then(response => response.json())
10.then(data => {
11setFormData({ title: data.title, body: data.body });
12})
13.catch(error => console.error('Error fetching post:', error));
14}, [postId]);
15
16// Handle input changes
17const handleInputChange = (event) => {
18const { name, value } = event.target;
19setFormData({ ...formData, [name]: value });
20};
21
22// Handle form submission
23const handleSubmit = (event) => {
24event.preventDefault();
25fetch(`https://jsonplaceholder.typicode.com/posts`, {
26method: 'POST', // Changed from PUT to POST
27headers: { 'Content-Type': 'application/json' },
28body: JSON.stringify(formData),
29})
30.then(response => response.json())
31.then(data => console.log('Post created:', data))
32.catch(error => console.error('Error creating post:', error));
33};
34
35return (
36<div>
37<h2>Edit Post</h2>
38<form onSubmit={handleSubmit}>
39<div>
40<label htmlFor="title">Title:</label>
41<input
42type="text"
43id="title"
44name="title"
45value={formData.title}
46onChange={handleInputChange}
47required
48/>
49</div>
50<div>
51<label htmlFor="body">Body:</label>
52<textarea
53id="body"
54name="body"
55value={formData.body}
56onChange={handleInputChange}
57required
58></textarea>
59</div>
60<button type="submit">Create Post</button>
61</form>
62</div>
63);
64};
65