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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for localhost_on_colab-0.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9724c90f3447822d77d6958ca9850544220208de8f19774cbcc6b78c44c9fba2 |
|
MD5 | e87f8821ab55d96969e29d7de1007bca |
|
BLAKE2b-256 | b032d680365525f4a71fc68bdce5ae16f3f04fe0f61cfe96757a2a7f475281be |