Browse Source

some work

cjs3
Stephen Lorenz 3 years ago
parent
commit
dd191fd4d9
  1. 17
      cjsd/app.py
  2. 33
      cjsd/database.py
  3. 4
      run_cjsd

17
cjsd/app.py

@ -1,26 +1,33 @@
#!/usr/bin/env python3
import os
import json
import falcon
from falcon import API
from database import NewDatabaseResource
PKG_DIR = os.path.dirname(os.path.abspath(__file__))
# TODO: serve overall status of the cjsd
class HomeResource:
class AppResource:
def on_get(self, req, resp):
body = json.dumps({
'version': '3.0.0'
'version': '3.0.0',
'pkg_dir': PKG_DIR
})
resp.body = body
_MODULES = {
'/': HomeResource
ROUTES = {
'/': AppResource,
'/database/new': NewDatabaseResource,
}
def create_api():
api = API()
for uri, Res in _MODULES.items():
for uri, Res in ROUTES.items():
api.add_route(uri, Res())
return api

33
cjsd/database.py

@ -1,5 +1,7 @@
#!/usr/bin/env python3
import json
# pip modules
import click
@ -61,6 +63,36 @@ def database_skeleton(root):
raise
# BEGIN command-line interface
'''
class DatabaseManager:
_CHUNK_SIZE_BYTES = 1024
def __init__(self):
self.database = None
def get_database(fn):
def wrapper(*args, **kwargs):
db =
def connect(self, database_name):
pass
def disconnect(self):
pass
'''
class NewDatabaseResource:
def on_post(self, req, resp):
try:
database_name = req.media.get('database_name')
except:
raise
resp.body = json.dumps({
'database': database_name
})
@click.group()
@click.pass_context
@ -81,6 +113,7 @@ def database(ctx):
create_dir(database_dir)
@database.command()
@click.argument('database_name')
@click.pass_context

4
run_cjsd

@ -0,0 +1,4 @@
#!/usr/bin/env bash
cd cjsd
../.venv/bin/gunicorn app:api --reload
Loading…
Cancel
Save