Spaces:
Running
on
L40S
Running
on
L40S
| import os | |
| from flask import Flask, render_template_string | |
| app = Flask(__name__) | |
| # HTML Template with embedded CSS for a clean look | |
| HTML_TEMPLATE = """ | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Docker on Hugging Face Spaces</title> | |
| <style> | |
| body { | |
| font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; | |
| margin: 0; | |
| padding: 0; | |
| background-color: #f5f5f5; | |
| color: #333; | |
| display: flex; | |
| flex-direction: column; | |
| min-height: 100vh; | |
| } | |
| /* Header Styling */ | |
| header { | |
| background-color: #fff; | |
| padding: 1rem 2rem; | |
| box-shadow: 0 2px 4px rgba(0,0,0,0.05); | |
| display: flex; | |
| justify-content: flex-start; | |
| align-items: center; | |
| } | |
| .brand-link { | |
| text-decoration: none; | |
| color: #007bff; | |
| font-weight: 600; | |
| font-size: 1rem; | |
| transition: color 0.2s; | |
| } | |
| .brand-link:hover { | |
| color: #0056b3; | |
| text-decoration: underline; | |
| } | |
| /* Main Content Styling */ | |
| main { | |
| flex: 1; | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| justify-content: center; | |
| padding: 2rem; | |
| text-align: center; | |
| } | |
| .card { | |
| background: white; | |
| padding: 3rem; | |
| border-radius: 12px; | |
| box-shadow: 0 4px 6px rgba(0,0,0,0.05); | |
| max-width: 600px; | |
| width: 100%; | |
| } | |
| h1 { | |
| margin-top: 0; | |
| color: #111; | |
| } | |
| p { | |
| color: #666; | |
| line-height: 1.6; | |
| } | |
| .status-badge { | |
| display: inline-block; | |
| margin-top: 1rem; | |
| padding: 0.25rem 0.75rem; | |
| background-color: #e6fffa; | |
| color: #047481; | |
| border-radius: 9999px; | |
| font-size: 0.875rem; | |
| font-weight: 500; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <!-- Header Section with Required Link --> | |
| <header> | |
| <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="brand-link"> | |
| Built with anycoder | |
| </a> | |
| </header> | |
| <!-- Main Content --> | |
| <main> | |
| <div class="card"> | |
| <h1>Docker Space Running</h1> | |
| <p> | |
| Your containerized application is successfully running on Hugging Face Spaces. | |
| This page is being served by a Flask application running inside a Docker container. | |
| </p> | |
| <div class="status-badge">● System Operational</div> | |
| </div> | |
| </main> | |
| </body> | |
| </html> | |
| """ | |
| def home(): | |
| """Render the main landing page.""" | |
| return render_template_string(HTML_TEMPLATE) | |
| if __name__ == "__main__": | |
| # Hugging Face Spaces expects the app to run on port 7860 | |
| # We bind to 0.0.0.0 to accept connections from outside the container | |
| port = int(os.environ.get("PORT", 7860)) | |
| app.run(host="0.0.0.0", port=port) |