Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

417
Views
incrustando jupyter notebook/google colab en la aplicación Django

Quería crear un sitio web e incorporar la funcionalidad del cuaderno jupyter de poder crear celdas y ejecutar el código python dentro de mi sitio web.

Para crear un sitio web, estoy usando Django y me gustaría incrustar Google Collab o Jupyter Notebook.

Por cierto, he investigado lo suficiente y me he quedado atascado con los enlaces de StackOverflow donde no hay respuesta sobre esto o sobre el que quieren usar django en jupyter notebook.

Gracias de antemano por cualquier orientación o cualquier referencia que puedan proporcionar.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Tienes muchas opciones para hacerlo:

Nota: Usé "jupyter-lab", puedes usar "jupyter notebook"

1- La primera opción para redirigir a "cuaderno jupyter"

django view.py

 from django.shortcuts import redirect,HttpResponse import subprocess import time def open_jupiter_notbook(request): b= subprocess.check_output("jupyter-lab list".split()).decode('utf-8') if "9999" not in b: a=subprocess.Popen("jupyter-lab --no-browser --port 9999".split()) start_time = time.time() unreachable_time = 10 while "9999" not in b: timer = time.time() elapsed_time = timer-start_time b= subprocess.check_output("jupyter-lab list".split()).decode('utf-8') if "9999" in b: break if elapsed_time > unreachable_time: return HttpResponse("Unreachable") path = b.split('\n')[1].split('::',1)[0] #You can here add data to your path if you want to open file or anything return redirect(path)

si desea implementarlo en la plantilla en lugar de redirigir, puede usar el siguiente código en la plantilla de Django:

 <iframe src="{% url 'open_jupiter_notbook' %}" width= 600px height=200px></iframe>

2- La segunda opción:

simplemente use los comandos de jupyter notebook usando este subprocess.check_output("your command".split())

over 4 years ago · Santiago Trujillo Report

0

Expórtelo primero y luego impórtelo, busque aquí una buena explicación

 from google.colab import files src = list(files.upload().values())[0] open('mylib.py','wb').write(src) import mylib
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!