added frontend and script examples

This commit is contained in:
CaffeineFueled 2025-04-15 23:33:44 +02:00
parent 368c4de6fe
commit 61b10a2bc2
6 changed files with 385 additions and 0 deletions

33
frontend/README.md Normal file
View file

@ -0,0 +1,33 @@
# Static2API Frontend
This is a simple frontend that displays data from the Static2API application. It's designed to work with the API without requiring any changes to the container or backend.
## Usage
1. Start the Static2API application either directly or via container:
```
python main.py
```
or
```
./run_container.sh
```
2. Open the `index.html` file in your browser:
- You can use any static file server
- Or simply open the file directly in your browser
3. The frontend will fetch data from the following endpoints:
- `/` - Root endpoint
- `/api/users` - Users data
- `/api/contacts` - Contacts data
## CORS Support
The FastAPI application has been updated with CORS middleware to allow cross-origin requests from this frontend. This means you can:
1. Open the HTML file directly in your browser
2. Access the API endpoints without CORS restrictions
3. Serve the frontend from any static file server
No additional configuration is needed for CORS support.