Commit ce28b31e authored by TheTechRobo's avatar TheTechRobo
Browse files

Use docstrings for API docs

parent bf080a05
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -17,7 +17,11 @@ async def ui():

@app.route("/api")
async def api():
    return render_template("api.html", fields={"id": "The interpreted video ID.", "status": "bad.id if invalid ID.", "keys": "Array of all the service keys."}, services={"archived": "Whether the video is archived or not.", "available": "A link to the archived material if it can be produced; False otherwise.", "capcount": "The number of captures. Currently deprecated - the capture count sent may or may not be the true number of captures. However, it will always be a positive non-zero number if the video is archived.", "lastupdated": "The timestamp the data was retrieved from the server. Used internally to expire cache entries.", "name": "The name of the service. Used in the UI.", "note": "A footnote about the service. This could be different depending on conditions. For example, the Internet Archive has an extra passage if the item is dark.", "rawraw": "The data used to check whether the video is archived on that particular service. For example, for GhostArchive, it would be the HTTP status code.", "suppl": "Supplemental error message. Not used and currently inconsistent with what it returns and when.", "metaonly": "True if only the metadata is archived. This value should not be relied on!", "comments": "True if the comments are archived. This value should not be relied on!"})
    responseDocstring = lostmediafinder.Response.__doc__
    serviceDocstring = lostmediafinder.Service.__doc__
    # TODO: Parse that
    # This works fine for now tho
    return render_template("api.html", fields=responseDocstring, services=serviceDocstring, type=type)

@app.route("/nojs")
async def formsubmit():
+26 −14
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ body {
    <b>Fields</b>
    <br>
    <dl>
      {% if fields is mapping %}
        {% for field, value in fields.items() %}
          <dt><code>
              {{ field }}
@@ -22,14 +23,25 @@ body {
          <dd>{{value}}
          </dd>
        {% endfor %}
      {% elif fields is string %}
        {{ fields.strip().replace("\n", "<br>") | safe }}
      {% else %}
        Fail
      {% endif %}
    </dl>
    <b>Service Keys</b>
    <b>Service Objects</b>
    <p>One object for every service searched.</p>
    {% if services is mapping %}
      <dl>
        {% for field, value in services.items() %}
          <dt><code>{{field}}</code></dt>
          <dd>{{value}}</dd>
        {%endfor%}
      </dl>
    {% elif services is string %}
      {{ services.strip().replace("\n", "<br>") | safe }}
    {% else %}
      fail
    {% endif %}
  </body>
</html>