apiliter 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- apiliter-1.0.0/LICENSE +21 -0
- apiliter-1.0.0/PKG-INFO +24 -0
- apiliter-1.0.0/README.md +4 -0
- apiliter-1.0.0/pyproject.toml +3 -0
- apiliter-1.0.0/setup.cfg +33 -0
- apiliter-1.0.0/src/apiliter/__init__.py +3 -0
- apiliter-1.0.0/src/apiliter/core.py +136 -0
- apiliter-1.0.0/src/apiliter.egg-info/PKG-INFO +24 -0
- apiliter-1.0.0/src/apiliter.egg-info/SOURCES.txt +11 -0
- apiliter-1.0.0/src/apiliter.egg-info/dependency_links.txt +1 -0
- apiliter-1.0.0/src/apiliter.egg-info/requires.txt +4 -0
- apiliter-1.0.0/src/apiliter.egg-info/top_level.txt +1 -0
apiliter-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Asinerum Conlang Project
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
apiliter-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: apiliter
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Literp Compact Server Lib
|
|
5
|
+
Home-page: https://github.com/asinerum/apiliter
|
|
6
|
+
Author: Asinerum Conlang Project
|
|
7
|
+
Author-email: asinerum.com@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.7
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: backio>=1.0.0
|
|
16
|
+
Requires-Dist: fastapi>=0.122.1
|
|
17
|
+
Requires-Dist: formatize>=1.0.4
|
|
18
|
+
Requires-Dist: uvicorn>=0.38.0
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
Detailed tips, tricks, and examples, can be found at project's repository
|
|
22
|
+
https://github.com/asinerum/apiliter
|
|
23
|
+
|
|
24
|
+
(C) 2026 Asinerum Conlang Project
|
apiliter-1.0.0/README.md
ADDED
apiliter-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
name = apiliter
|
|
3
|
+
version = 1.0.0
|
|
4
|
+
author = Asinerum Conlang Project
|
|
5
|
+
author_email = asinerum.com@gmail.com
|
|
6
|
+
description = Literp Compact Server Lib
|
|
7
|
+
long_description = file: README.md
|
|
8
|
+
long_description_content_type = text/markdown
|
|
9
|
+
url = https://github.com/asinerum/apiliter
|
|
10
|
+
license = MIT
|
|
11
|
+
classifiers =
|
|
12
|
+
Programming Language :: Python :: 3
|
|
13
|
+
License :: OSI Approved :: MIT License
|
|
14
|
+
Operating System :: OS Independent
|
|
15
|
+
|
|
16
|
+
[options]
|
|
17
|
+
package_dir =
|
|
18
|
+
= src
|
|
19
|
+
packages = find:
|
|
20
|
+
python_requires = >=3.7
|
|
21
|
+
install_requires =
|
|
22
|
+
backio >= 1.0.0
|
|
23
|
+
fastapi >= 0.122.1
|
|
24
|
+
formatize >= 1.0.4
|
|
25
|
+
uvicorn >= 0.38.0
|
|
26
|
+
|
|
27
|
+
[options.packages.find]
|
|
28
|
+
where = src
|
|
29
|
+
|
|
30
|
+
[egg_info]
|
|
31
|
+
tag_build =
|
|
32
|
+
tag_date = 0
|
|
33
|
+
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
from fastapi import FastAPI, Cookie, Response, Request
|
|
2
|
+
from fastapi.middleware.cors import CORSMiddleware
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
import uvicorn
|
|
6
|
+
|
|
7
|
+
from backio import *
|
|
8
|
+
from backio import login as pure_login
|
|
9
|
+
|
|
10
|
+
from formatize import get_modules_from_yaml, dict_extract
|
|
11
|
+
|
|
12
|
+
Modules = get_modules_from_yaml()
|
|
13
|
+
|
|
14
|
+
os.environ[ENV_SECRET] = str(os.urandom(24))
|
|
15
|
+
|
|
16
|
+
APP_HOST = host_for_api
|
|
17
|
+
APP_PORT = port_for_api
|
|
18
|
+
|
|
19
|
+
app = FastAPI()
|
|
20
|
+
app.add_middleware(
|
|
21
|
+
CORSMiddleware,
|
|
22
|
+
allow_origins=http_allowed_origins(),
|
|
23
|
+
allow_credentials=True,
|
|
24
|
+
allow_methods=['*'],
|
|
25
|
+
allow_headers=['*'],)
|
|
26
|
+
|
|
27
|
+
#########################################################
|
|
28
|
+
|
|
29
|
+
@app.get('/hello')
|
|
30
|
+
@app.post('/hello')
|
|
31
|
+
def say_hello():
|
|
32
|
+
return hello()
|
|
33
|
+
|
|
34
|
+
@app.get('/hello/zone')
|
|
35
|
+
@app.post('/hello/zone')
|
|
36
|
+
def say_hello_zone(id: int):
|
|
37
|
+
return hello_zone(zoneid=id)
|
|
38
|
+
|
|
39
|
+
@app.get('/module')
|
|
40
|
+
@app.post('/module')
|
|
41
|
+
def say_module(function: str):
|
|
42
|
+
return what_module(Modules, function)
|
|
43
|
+
|
|
44
|
+
@app.get('/access')
|
|
45
|
+
@app.post('/access')
|
|
46
|
+
def say_access(function: str):
|
|
47
|
+
return {
|
|
48
|
+
'access': get_afunc(function, pop=hstr),
|
|
49
|
+
'notice': get_erole(function),
|
|
50
|
+
'data': get_edata(function),
|
|
51
|
+
'argument': get_afarg(function)}
|
|
52
|
+
|
|
53
|
+
@app.get('/timeout')
|
|
54
|
+
@app.post('/timeout')
|
|
55
|
+
def say_timeout():
|
|
56
|
+
return {'session_timeout': token_expire_minutes}
|
|
57
|
+
|
|
58
|
+
@app.get('/client')
|
|
59
|
+
@app.post('/client')
|
|
60
|
+
def client(request: Request, access_token: str=Cookie(None)):
|
|
61
|
+
return {'host': request.client.host, 'port': request.client.port}
|
|
62
|
+
|
|
63
|
+
@app.get('/login', response_model=Token)
|
|
64
|
+
@app.post('/login', response_model=Token)
|
|
65
|
+
def login(username: str, password: str, response: Response):
|
|
66
|
+
return do_login(username, password, response)
|
|
67
|
+
|
|
68
|
+
@app.get('/logout')
|
|
69
|
+
@app.post('/logout')
|
|
70
|
+
def logout(response: Response):
|
|
71
|
+
return do_logout(response)
|
|
72
|
+
|
|
73
|
+
@app.get('/me', response_model=User)
|
|
74
|
+
@app.post('/me', response_model=User)
|
|
75
|
+
def me(access_token: str=Cookie(None)):
|
|
76
|
+
return get_current_user(access_token)
|
|
77
|
+
|
|
78
|
+
#########################################################
|
|
79
|
+
|
|
80
|
+
@app.get('/init/admin')
|
|
81
|
+
@app.post('/init/admin')
|
|
82
|
+
def init_admin(adminpass: str=DEFPASSWORD):
|
|
83
|
+
return init_admin_database(adminpass)
|
|
84
|
+
|
|
85
|
+
@app.get('/init/zone')
|
|
86
|
+
@app.post('/init/zone')
|
|
87
|
+
def init_zone(zoneid: int, access_token: str=Cookie(None)):
|
|
88
|
+
return init_zone_database(zoneid, access_token)
|
|
89
|
+
|
|
90
|
+
@app.get('/init/accounting')
|
|
91
|
+
@app.post('/init/accounting')
|
|
92
|
+
def init_accounting(zoneid: int, access_token: str=Cookie(None)):
|
|
93
|
+
return init_accounting_database(zoneid, access_token)
|
|
94
|
+
|
|
95
|
+
@app.get('/data/dump/tables')
|
|
96
|
+
@app.post('/data/dump/tables')
|
|
97
|
+
def data_dump_tables(zone: str, access_token: str=Cookie(None)):
|
|
98
|
+
return dump_database_tables(zone, access_token)
|
|
99
|
+
|
|
100
|
+
@app.get('/data/dump')
|
|
101
|
+
@app.post('/data/dump')
|
|
102
|
+
def data_dump(zone: str, table: str, idr: str='', access_token: str=Cookie(None)):
|
|
103
|
+
return dump_zone_database(zone, table, access_token, idr=[] if not idr else idr.split(','))
|
|
104
|
+
|
|
105
|
+
@app.get('/data/load')
|
|
106
|
+
@app.post('/data/load')
|
|
107
|
+
def data_load(csv: str, zone: str, table: str, access_token: str=Cookie(None)):
|
|
108
|
+
return load_zone_database(csv, zone, table, access_token)
|
|
109
|
+
|
|
110
|
+
#########################################################
|
|
111
|
+
|
|
112
|
+
@app.get('/call')
|
|
113
|
+
@app.post('/call')
|
|
114
|
+
def call(function: str, jsondata: str='{}', module: str='', access_token: str=Cookie(None)):
|
|
115
|
+
if not module: module = function_module2(module_access, function)
|
|
116
|
+
run = popattr(Modules.get(module), function)
|
|
117
|
+
if not run: return error_unexpect(ERR_FUNCTION)
|
|
118
|
+
try:
|
|
119
|
+
return run(jsondata, access_token)
|
|
120
|
+
except Exception as e:
|
|
121
|
+
return error_unexpect(e)
|
|
122
|
+
|
|
123
|
+
def app_init():
|
|
124
|
+
import argparse
|
|
125
|
+
parser = argparse.ArgumentParser(description=f"LITERP COMPACT API SERVER {app_consts.get('VERSION')}")
|
|
126
|
+
parser.add_argument('-p', '--port', type=int, default=APP_PORT, help=f'apply server http port, default "{APP_PORT}"')
|
|
127
|
+
parser.add_argument('-d', '--db', type=str, default='sqlite', help=f'apply database engine, default "sqlite"')
|
|
128
|
+
parser.add_argument('-c', '--cert', type=str, default='literp.pem', help=f'SSL certificate file path')
|
|
129
|
+
parser.add_argument('-k', '--key', type=str, default='literp-key.pem', help=f'SSL key file path')
|
|
130
|
+
args = parser.parse_args()
|
|
131
|
+
if (db:=dict_extract(app_consts, f'database_engines.{args.db}')):
|
|
132
|
+
set_engine(getattr(this, db.get('engine')))
|
|
133
|
+
set_connect(getattr(this, db.get('connect')))
|
|
134
|
+
return app, APP_HOST, args.port, args.cert, args.key
|
|
135
|
+
|
|
136
|
+
#########################################################
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: apiliter
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Literp Compact Server Lib
|
|
5
|
+
Home-page: https://github.com/asinerum/apiliter
|
|
6
|
+
Author: Asinerum Conlang Project
|
|
7
|
+
Author-email: asinerum.com@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.7
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: backio>=1.0.0
|
|
16
|
+
Requires-Dist: fastapi>=0.122.1
|
|
17
|
+
Requires-Dist: formatize>=1.0.4
|
|
18
|
+
Requires-Dist: uvicorn>=0.38.0
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
Detailed tips, tricks, and examples, can be found at project's repository
|
|
22
|
+
https://github.com/asinerum/apiliter
|
|
23
|
+
|
|
24
|
+
(C) 2026 Asinerum Conlang Project
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.cfg
|
|
5
|
+
src/apiliter/__init__.py
|
|
6
|
+
src/apiliter/core.py
|
|
7
|
+
src/apiliter.egg-info/PKG-INFO
|
|
8
|
+
src/apiliter.egg-info/SOURCES.txt
|
|
9
|
+
src/apiliter.egg-info/dependency_links.txt
|
|
10
|
+
src/apiliter.egg-info/requires.txt
|
|
11
|
+
src/apiliter.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
apiliter
|