Spaces:
Running
Running
import os | |
import requests | |
import json | |
from io import BytesIO | |
from flask import Flask, jsonify, render_template, request, send_file | |
app = Flask(__name__) | |
def index(): | |
# Basic HTML string | |
html = ''' | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Dynamic HTML Page</title> | |
<style> | |
body { font-family: Arial, sans-serif; margin: 40px; } | |
.container { max-width: 800px; margin: 0 auto; } | |
.highlight { background-color: #f0f0f0; padding: 20px; } | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<h1>Welcome to Flask</h1> | |
<div class="highlight"> | |
<p>This HTML was rendered directly from a string!</p> | |
</div> | |
</div> | |
</body> | |
</html> | |
''' | |
return html | |
def llm_text(library): | |
# Replace this URL with your actual file URL | |
remote_url = f"https://huggingface.co/mishig/llms-txt/raw/main/{library}.txt" | |
try: | |
# Fetch the remote file | |
response = requests.get(remote_url) | |
response.raise_for_status() # Raise an exception for bad status codes | |
# Return the content as a text file | |
return Response( | |
response.text, | |
mimetype='text/plain', | |
headers={ | |
'Content-Disposition': 'inline', | |
'Cache-Control': 'no-cache' | |
} | |
) | |
except requests.RequestException as e: | |
return f"Error fetching file: {str(e)}", 500 | |
if __name__ == "__main__": | |
app.run(host="0.0.0.0", port=7860) | |