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 = ''' Hugging Face Docs /llms.txt /llms.txt files for Hugging Face Docs ''' return html @app.route('//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)