Skip to main content

Helps you run localhost stuff on colab

Project description

localhost-on-colab

Thin wrapper to help you run localhost stuff on colab.

Running webapps(or other localhost stuff) on the colab GPU is much easier with this module.

Usage

from localhost_on_colab.core import LocalHostOnColab

bridge = LocalHostOnColab()

url = bridge.run(
    function = some_function,
    kwargs = {},
    port = 5000
)

print(url)

Flask Example

Imports + mininmal flask app

from flask import Flask
from localhost_on_colab.core import LocalHostOnColab

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello :)"

Running the bridge

bridge = LocalHostOnColab()

url = bridge.run(
    function = app.run,
    kwargs = {'port': 8989},
    port = 8989,
)

print(url)

FastAPI example

Imports + mininmal fastAPI app

import uvicorn
from fastapi import FastAPI
from localhost_on_colab.core import LocalHostOnColab

app = FastAPI()

@app.get('/')
async def home():
  return "Hello Santa"

Running the bridge

bridge2 = LocalHostOnColab()

url = bridge2.run(
    function = uvicorn.run,
    kwargs = {
        'app': app, 
        'port': 9999
    },
    port = 9999,
)

print(url)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

localhost-on-colab-0.0.0.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

localhost_on_colab-0.0.0-py3-none-any.whl (2.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page