final stage of the app

This commit is contained in:
2025-07-15 14:32:57 +03:00
parent 94f006d458
commit b94d2ebbd6
29 changed files with 1498 additions and 1124 deletions

View File

@@ -1,162 +0,0 @@
#!/usr/bin/env python3
"""
Test script for the new Dynamic Link Page feature
This will create a link page and demonstrate its functionality
"""
import requests
import json
import time
# Server URL
BASE_URL = "http://localhost:5000"
def test_create_link_page():
"""Test creating a dynamic link page"""
print("🚀 Testing Dynamic Link Page Creation...")
data = {
"title": "My Awesome Links",
"description": "A collection of my favorite resources and tools",
"foreground_color": "#1565c0",
"background_color": "#ffffff",
"style": "rounded",
"size": 12
}
response = requests.post(f"{BASE_URL}/api/create_link_page", json=data)
if response.status_code == 200:
result = response.json()
if result['success']:
print(f"✅ Link page created successfully!")
print(f"📄 Page ID: {result['page_id']}")
print(f"🔗 Public URL: {result['page_url']}")
print(f"✏️ Edit URL: {result['edit_url']}")
print(f"📱 QR ID: {result['qr_id']}")
return result
else:
print(f"❌ Error: {result['error']}")
else:
print(f"❌ HTTP Error: {response.status_code}")
return None
def test_add_links(page_id):
"""Test adding links to the page"""
print(f"\n📝 Adding links to page {page_id}...")
links_to_add = [
{
"title": "GitHub",
"url": "https://github.com",
"description": "The world's leading software development platform"
},
{
"title": "Stack Overflow",
"url": "https://stackoverflow.com",
"description": "Q&A platform for programmers"
},
{
"title": "MDN Web Docs",
"url": "https://developer.mozilla.org",
"description": "Complete web development documentation"
},
{
"title": "VS Code",
"url": "https://code.visualstudio.com",
"description": "Free source-code editor by Microsoft"
}
]
for link_data in links_to_add:
response = requests.post(f"{BASE_URL}/api/link_pages/{page_id}/links", json=link_data)
if response.status_code == 200:
result = response.json()
if result['success']:
print(f"✅ Added: {link_data['title']}")
else:
print(f"❌ Failed to add {link_data['title']}: {result['error']}")
else:
print(f"❌ HTTP Error adding {link_data['title']}: {response.status_code}")
def test_view_page(page_id):
"""Test viewing the page data"""
print(f"\n👀 Viewing page {page_id}...")
response = requests.get(f"{BASE_URL}/api/link_pages/{page_id}")
if response.status_code == 200:
page_data = response.json()
print(f"✅ Page loaded successfully!")
print(f" Title: {page_data['title']}")
print(f" Description: {page_data['description']}")
print(f" Links: {len(page_data['links'])}")
print(f" Views: {page_data['view_count']}")
for i, link in enumerate(page_data['links'], 1):
print(f" {i}. {link['title']}{link['url']}")
else:
print(f"❌ HTTP Error: {response.status_code}")
def test_update_link(page_id, link_id):
"""Test updating a link"""
print(f"\n✏️ Updating link {link_id}...")
update_data = {
"title": "GitHub (Updated)",
"description": "The world's leading software development platform - Now with Copilot!"
}
response = requests.put(f"{BASE_URL}/api/link_pages/{page_id}/links/{link_id}", json=update_data)
if response.status_code == 200:
result = response.json()
if result['success']:
print(f"✅ Link updated successfully!")
else:
print(f"❌ Failed to update link: {result['error']}")
else:
print(f"❌ HTTP Error: {response.status_code}")
def main():
"""Run the comprehensive test"""
print("🎯 Dynamic Link Page Feature Test")
print("=" * 50)
# Create a new link page
result = test_create_link_page()
if not result:
print("❌ Failed to create link page. Exiting.")
return
page_id = result['page_id']
page_url = result['page_url']
edit_url = result['edit_url']
# Add some links
test_add_links(page_id)
# View the page data
test_view_page(page_id)
print(f"\n🎉 Test completed successfully!")
print(f"📱 QR Code Points to: {page_url}")
print(f"✏️ Edit Interface: {edit_url}")
print(f"🌐 Public Page: {page_url}")
print("\nNow you can:")
print("1. Scan the QR code to visit the public page")
print("2. Open the edit URL to manage links")
print("3. Share the QR code - it will always point to the same page!")
print("4. Update links anytime without changing the QR code")
if __name__ == "__main__":
try:
main()
except requests.exceptions.ConnectionError:
print("❌ Cannot connect to the server. Make sure the QR Code Manager is running on localhost:5000")
print("Start the server with: python app.py")
except Exception as e:
print(f"❌ Unexpected error: {e}")