Spaces:
Build error
Build error
File size: 1,265 Bytes
e8c85ec 3d07878 e8c85ec 3d07878 e8c85ec 3d07878 e8c85ec 3d07878 7ae623c d7edd64 06bffd3 7ae623c |
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 |
import subprocess
import sys
# Function to install a package using pip
def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
# Install Streamlit if it's not already installed
try:
import streamlit as st
except ImportError:
print("Streamlit is not installed. Installing now...")
install("streamlit")
import streamlit as st
# Streamlit app code
st.set_page_config(page_title="Hello World App")
st.title("Hello, World!")
st.write("This is a Streamlit app that says 'Hello, World!'.")
# Add some interactivity (optional)
user_name = st.text_input("Enter your name:")
if user_name:
st.write(f"Hello, {user_name}!")
try:
import Flask, request, jsonify
except ImportError:
print("Flask is not installed. Installing now...")
install("flask")
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route("/generate", methods=["POST"])
def generate():
data = request.json
prompt = data.get("prompt", "")
# Simulate a response from the model
response = f"Generated response for: {prompt}"
return jsonify({"response": response})
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8001)
#Run the server:
#```bash
##python model_server.py
#```
|