Переглянути джерело

migrate REST endpoint to submodule

Pi 2 роки тому
батько
коміт
efbe9f518c
3 змінених файлів з 1 додано та 25 видалено
  1. 1 1
      prayer-generator
  2. 0 23
      pyapi.py
  3. 0 1
      requirements.txt

+ 1 - 1
prayer-generator

@@ -1 +1 @@
-Subproject commit d61f9621beff0f6c18e89e4d8618cfd3d2740c33
+Subproject commit a73be66cfa825d92b5810ba31a8405f70110cdf4

+ 0 - 23
pyapi.py

@@ -1,23 +0,0 @@
-from bottle import route, run, template, response
-import psycopg
-from psycopg import Cursor
-import os
-user = os.getenv('USER')
-password = os.getenv('PASSWORD')
-host = 'host=localhost'
-conn: Cursor = psycopg.connect(f"{host} dbname=pgdb user={user} {password}")
-statement = """SELECT
-  table_to_xml_and_xmlschema('pg_random_view_default_if_null'::regclass,
-  false, false, ''::text);"""
-heading = """<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet type="text/xsl" href="https://shandan.one/xml/pg_view_style.xsl"?>
-"""
-
-@route('/pyapi/random')
-def index():
-    with conn.cursor() as cur:
-        xml = cur.execute(statement).fetchone()[0]
-    response.content_type = 'application/xhtml+xml; charset=utf-8'
-    return f"{heading}{xml}"
-
-run(host='192.168.0.20', port=11888)

+ 0 - 1
requirements.txt

@@ -1 +0,0 @@
-bottle