File size: 1,723 Bytes
db6e2f8 fe80588 db6e2f8 2c91845 9904067 2c91845 9904067 82addbf 9904067 2c91845 db6e2f8 207a252 db6e2f8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import os
import requests
import json
from io import BytesIO
from flask import Flask, jsonify, render_template, request, send_file, Response
app = Flask(__name__)
@app.route("/")
def index():
# Basic HTML string
html = '''
<!DOCTYPE html>
<html>
<head>
<title>Hugging Face Docs /llms.txt</title>
</head>
<body>
<a href="https://llmstxt.org/">/llms.txt</a> files for <a href="https://huggingface.co/docs">Hugging Face Docs</a>
<ul>
<li><a href="/transformers/llms.txt">/transformers/llms.txt</a></li>
<li><a href="/diffusers/llms.txt">/diffusers/llms.txt</a></li>
<li><a href="/accelerate/llms.txt">//accelerate/llms.txt</a></li>
<li><a href="/huggingface_hub/llms.txt">/huggingface_hub/llms.txt</a></li>
<li><a href="/accelerate/llms.txt">/accelerate/llms.txt</a></li>
</ul>
</body>
</html>
'''
return html
@app.route('/<library>/llms.txt')
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)
|