p2
This commit is contained in:
@@ -2,7 +2,7 @@ import requests
|
|||||||
|
|
||||||
def get_quote():
|
def get_quote():
|
||||||
try:
|
try:
|
||||||
# Folosim API-ul Quotable pentru a primi și autorul
|
# Schimbăm la Quotable pentru a primi autorul
|
||||||
response = requests.get("https://api.quotable.io/random", timeout=10)
|
response = requests.get("https://api.quotable.io/random", timeout=10)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
data = response.json()
|
data = response.json()
|
||||||
@@ -10,13 +10,13 @@ def get_quote():
|
|||||||
quote = data.get('content', 'No quote found')
|
quote = data.get('content', 'No quote found')
|
||||||
author = data.get('author', 'Unknown')
|
author = data.get('author', 'Unknown')
|
||||||
|
|
||||||
# Salvăm formatat pentru Discord
|
# Formatăm textul care va ajunge pe Discord
|
||||||
with open("quote.txt", "w", encoding="utf-8") as f:
|
with open("quote.txt", "w", encoding="utf-8") as f:
|
||||||
f.write(f"📜 *\"{quote}\"*\n\n✍️ **Autor:** {author}")
|
f.write(f"📜 *\"{quote}\"*\n\n✍️ **Autor:** {author}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
with open("quote.txt", "w", encoding="utf-8") as f:
|
with open("quote.txt", "w", encoding="utf-8") as f:
|
||||||
f.write(f"⚠️ Nu am putut prelua citatul. Eroare: {str(e)}")
|
f.write(f"⚠️ Eroare la preluare: {str(e)}")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
get_quote()
|
get_quote()
|
||||||
@@ -6,7 +6,7 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
dir('project2') {
|
dir('project2') {
|
||||||
sh "docker build -t quotes-app ."
|
sh "docker build --no-cache -t quotes-app ."
|
||||||
echo "🔍 Verificăm sintaxa codului..."
|
echo "🔍 Verificăm sintaxa codului..."
|
||||||
sh "docker run --rm quotes-app python -m py_compile famousquotes.py"
|
sh "docker run --rm quotes-app python -m py_compile famousquotes.py"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user