Files
fastapi-inventory/templates/index.html
grabowski 664f58cefe Consolidate search endpoints for better API organization
- Removed duplicate /api/search endpoint
- Kept /search as the main JSON API endpoint with proper documentation
- Added /search/form for web form submissions
- Updated HTML form to use /search/form endpoint
- Clear separation between API and web interface
- Media type enums still visible in /docs for API usage
- Maintains all functionality while reducing endpoint confusion
2025-08-11 16:50:57 +07:00

87 lines
3.6 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% extends "base.html" %}
{% block title %}Search Media - Media Inventory App{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">
<h2 class="card-title mb-0">🔍 Search Media</h2>
</div>
<div class="card-body">
{% if error %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endif %}
<form method="post" action="/search/form">
<div class="mb-3">
<label for="media_type" class="form-label">Media Type</label>
<select class="form-select" id="media_type" name="media_type" required>
<option value="">Select media type...</option>
<option value="book">📚 Book</option>
<option value="vinyl">🎵 Vinyl Record</option>
<option value="cd">💿 CD</option>
<option value="cassette">📼 Cassette</option>
</select>
</div>
<div class="mb-3">
<label for="query" class="form-label">Search Query</label>
<input type="text" class="form-control" id="query" name="query"
placeholder="Enter title, album name, or keywords..." required>
<div class="form-text">
For books: Enter book title or author name<br>
For music: Enter album title or song name
</div>
</div>
<div class="mb-3" id="artist-field" style="display: none;">
<label for="artist" class="form-label">Artist (Optional)</label>
<input type="text" class="form-control" id="artist" name="artist"
placeholder="Enter artist name...">
<div class="form-text">
Helps narrow down music search results
</div>
</div>
<button type="submit" class="btn btn-primary btn-lg w-100">
🔍 Search
</button>
</form>
</div>
</div>
<div class="mt-4">
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0"> How it works</h5>
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong>📚 Books:</strong> Searches OpenLibrary.org for book information</li>
<li><strong>🎵 Music (Vinyl/CD/Cassette):</strong> Searches Discogs.com for music releases</li>
<li><strong>🎯 Tips:</strong> Be specific with your search terms for better results</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<script>
document.getElementById('media_type').addEventListener('change', function() {
const artistField = document.getElementById('artist-field');
const selectedType = this.value;
if (selectedType === 'vinyl' || selectedType === 'cd' || selectedType === 'cassette') {
artistField.style.display = 'block';
} else {
artistField.style.display = 'none';
}
});
</script>
{% endblock %}