jupyterhub / the-littlest-jupyterhub

Simple JupyterHub distribution for 1-100 users on a single server
https://tljh.jupyter.org
BSD 3-Clause "New" or "Revised" License
1.04k stars 341 forks source link

Trying to get Simple Announcement Service to Work #156

Closed ynnelson closed 3 years ago

ynnelson commented 6 years ago

So I have been trying to get JupyterHub Simple Announcement Service to work all morning and I can quite seem to figure it out. I try to follow the link below but still can't get it to work. https://github.com/jupyterhub/jupyterhub/tree/master/examples/service-announcement

This is what I did:

  1. In the same folder where my config.yaml file is I added a jupyterhub_config.d folder in which I added a .py file that has the following:

    c.JupyterHub.services = [
        {
            'name': 'announcement',
            'url': 'http://127.0.0.1:8888',
            'command': ["python", "-m", "announcement"],
        }
    ]
    c.JupyterHub.template_paths = ["templates"]
  2. I added a templates folder in the same folder as config.yaml in which I have a page.html that contains the following:


{% extends "templates/page.html" %}
{% block announcement %}
<div class="container text-center announcement">
</div>
{% endblock %}

{% block script %}
{{ super() }}
<script>
$.get("/services/announcement/", function(data) {
    $(".announcement").html(data["announcement"]);
});
</script>
{% endblock %}
  1. I created services/announcement/ folders in which I have the announcement.py file

  2. I created an API token with my Control Panel and used it with 6. below

  3. Used tljh-config reload to restart Jupyterhub

  4. I then tried this without success:

    curl -X POST -H "Authorization: token <token>"                        \
    -d "{'announcement':'JupyterHub will be upgraded on August 14!'}"   \
    https://.../services/announcement

Any Idea what I am doing wrong here? Has anyone gotten this to work or attempted it ? Nothing ends up being posted on the Hub!

I have also tried to add a custom button in the nav bar that would link to our internal documentation but I can't get the Jinja templates to work. (I have no experience with Jinja which def does not help)

If I can get it to work I'd love to make add a Topic documentation to this project, I feel like this would be very useful!

Thank you

jkfm commented 4 years ago

Hi @ynnelson,

did you get this to work?

consideRatio commented 3 years ago

Hey I'm issue triaging this repo. I believe this is at this point a stale question without a clear action point of something to do within this specific github repo.

If someone ends up here with similar questions, I suggest using discourse.jupyter.org as a place to ask it! Thanks for being active members of the JupyterHub community!