Skip to main content

Web App Hosting

Projects can run web applications and make them accessible via HTTPS. Any application running on localhost in your project can be accessed externally.

Why Host Apps in Your Project?

Simple Deployment No separate hosting setup. Your project is already running - just start your app. Use Idle Compute When you’re not running notebooks, your project can host applications. Make use of the compute you’re already paying for. One Server, Multiple Uses Same environment for notebooks and apps. Share dependencies, data, and resources.

How It Works

  1. Your app runs on a local port (e.g., 5000)
  2. Alph creates a secure tunnel
  3. App is accessible at https://your-project.runalph.dev

Supported Frameworks

Streamlit

import streamlit as st

st.title('My Dashboard')
st.write('Hello from Alph!')
Run:
streamlit run app.py --server.port 5000

Gradio

import gradio as gr

def greet(name):
    return f"Hello {name}!"

demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch(server_port=5000, server_name="0.0.0.0")

Flask

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return '<h1>Hello from Alph!</h1>'

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000)

FastAPI

from fastapi import FastAPI
import uvicorn

app = FastAPI()

@app.get("/")
def read_root():
    return {"message": "Hello from Alph!"}

if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=5000)

Important Configuration

Bind to 0.0.0.0

Your app must bind to 0.0.0.0, not 127.0.0.1:
# ✓ Correct - accessible externally
app.run(host='0.0.0.0', port=5000)

# ✗ Wrong - only accessible locally
app.run(host='127.0.0.1', port=5000)

Default Port

The default port is 5000. Configure your project settings to use different ports.

Environment Variables

Set secrets in project settings → Environment Variables:
import os

api_key = os.getenv('API_KEY')
db_url = os.getenv('DATABASE_URL')

Running in Background

Using tmux

# Start session
tmux new -s webapp

# Run your app
python app.py

# Detach: Ctrl+B, then D

Using nohup

nohup python app.py > app.log 2>&1 &

# View logs
tail -f app.log

Troubleshooting

App Not Accessible

Check:
  • Is app running? (ps aux | grep python)
  • Bound to 0.0.0.0? (not 127.0.0.1)
  • Correct port? (default 5000)

Port Already in Use

# Find process using port
lsof -i :5000

# Kill it
kill <PID>

App Stops When Terminal Closes

Use tmux or nohup to keep apps running in background.

Security

Add Authentication

from flask_httpauth import HTTPBasicAuth

auth = HTTPBasicAuth()

@auth.verify_password
def verify(username, password):
    return username == 'admin' and password == os.getenv('PASSWORD')

@app.route('/')
@auth.login_required
def home():
    return 'Protected'

HTTPS

All runalph.dev URLs automatically use HTTPS.

Don’t Hardcode Secrets

# ✗ Wrong
api_key = "sk-1234567890"

# ✓ Correct
api_key = os.getenv('API_KEY')

Next Steps