Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from flask import Flask, send_from_directory
|
| 3 |
+
|
| 4 |
+
# Your Python function
|
| 5 |
+
def greet(name, intensity):
|
| 6 |
+
return "Hello, " + name + "!" * intensity
|
| 7 |
+
|
| 8 |
+
# Create Gradio backend (no UI)
|
| 9 |
+
backend = gr.Interface(fn=greet, inputs=["text", "number"], outputs="text")
|
| 10 |
+
|
| 11 |
+
# Launch Gradio backend in the background
|
| 12 |
+
backend.launch(prevent_thread_lock=True, server_name="0.0.0.0", server_port=7860)
|
| 13 |
+
|
| 14 |
+
# Optional: serve your custom HTML via Flask
|
| 15 |
+
app = Flask(__name__)
|
| 16 |
+
|
| 17 |
+
@app.route("/")
|
| 18 |
+
def index():
|
| 19 |
+
return send_from_directory(".", "home.html") # serve home.html
|
| 20 |
+
|
| 21 |
+
if __name__ == "__main__":
|
| 22 |
+
app.run(port=5000)
|