Compare commits
2 Commits
ba66c10ee3
...
ab19504738
Author | SHA1 | Date | |
---|---|---|---|
ab19504738 | |||
7ae5e613b7 |
31
.gitea/workflows/build.yaml
Normal file
31
.gitea/workflows/build.yaml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
name: devranta build
|
||||||
|
run-name: devranta async devRant api client build and test
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Pull repo
|
||||||
|
run: git pull
|
||||||
|
- name: List files in the repository
|
||||||
|
run: |
|
||||||
|
ls ${{ gitea.workspace }}
|
||||||
|
- name: Build new package
|
||||||
|
run: make build
|
||||||
|
- name: Install package
|
||||||
|
run: make install
|
||||||
|
- name: Run application
|
||||||
|
run: make run
|
||||||
|
- name: Test application
|
||||||
|
run: make test
|
||||||
|
- name: Push new packages
|
||||||
|
run: |
|
||||||
|
git add .
|
||||||
|
git config --global user.email "bot@molodetz.nl"
|
||||||
|
git config --global user.name "bot"
|
||||||
|
git commit -a -m "New build."
|
||||||
|
git push
|
||||||
|
|
32
Makefile
Normal file
32
Makefile
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
PYTHON=./.venv/bin/python
|
||||||
|
PIP=./.venv/bin/pip
|
||||||
|
BIN=./.venv/bin
|
||||||
|
ENV=./.venv/bin/activate
|
||||||
|
APP=form
|
||||||
|
|
||||||
|
all: ensure_env format install build test
|
||||||
|
|
||||||
|
ensure_env:
|
||||||
|
-@python3 -m venv .venv
|
||||||
|
|
||||||
|
install:
|
||||||
|
$(PIP) install -e .
|
||||||
|
|
||||||
|
format:
|
||||||
|
$(PIP) install shed
|
||||||
|
. $(ENV) && shed
|
||||||
|
|
||||||
|
build:
|
||||||
|
$(PIP) install build
|
||||||
|
$(PYTHON) -m build .
|
||||||
|
|
||||||
|
test:
|
||||||
|
$(PYTHON) -m unittest $(APP).tests
|
||||||
|
|
||||||
|
run:
|
||||||
|
$(BIN)/$(APP).serve
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
3
pyproject.toml
Normal file
3
pyproject.toml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
26
setup.cfg
Normal file
26
setup.cfg
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[metadata]
|
||||||
|
name = form
|
||||||
|
version = 1.0.0
|
||||||
|
description = REST Form builder and validator.
|
||||||
|
author = retoor
|
||||||
|
author_email = retoor@molodetz.nl
|
||||||
|
license = MIT
|
||||||
|
long_description = file: README.md
|
||||||
|
long_description_content_type = text/markdown
|
||||||
|
|
||||||
|
[options]
|
||||||
|
packages = find:
|
||||||
|
package_dir =
|
||||||
|
= src
|
||||||
|
python_requires = >=3.7
|
||||||
|
install_requires =
|
||||||
|
requests
|
||||||
|
app @ git+https://retoor.molodetz.nl/retoor/app
|
||||||
|
captcha
|
||||||
|
|
||||||
|
[options.packages.find]
|
||||||
|
where = src
|
||||||
|
|
||||||
|
[options.entry_points]
|
||||||
|
console_scripts =
|
||||||
|
form.serve = form.__main__:main
|
0
src/form/__init__.py
Normal file
0
src/form/__init__.py
Normal file
13
src/form/__main__.py
Normal file
13
src/form/__main__.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from app.app import argument_parser
|
||||||
|
|
||||||
|
from form.app import Application
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = argument_parser.parse_args()
|
||||||
|
app = Application(db_path="sqlite:///form.db", db_web=args.db_web)
|
||||||
|
app.run(host=args.host, port=args.port)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
27
src/form/app.py
Normal file
27
src/form/app.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
from app.app import Application as BaseApplication
|
||||||
|
from aiohttp import web
|
||||||
|
|
||||||
|
|
||||||
|
class Application(BaseApplication):
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
self.router.add_get("/", self.index_handler)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def forms_created(self):
|
||||||
|
return int(self.sget("forms_created", 0))
|
||||||
|
|
||||||
|
@forms_created.setter
|
||||||
|
def forms_created(self, value):
|
||||||
|
self.sset("forms_created", int(value))
|
||||||
|
|
||||||
|
async def index_handler(self,request):
|
||||||
|
self.forms_created += 1
|
||||||
|
print(self.forms_created)
|
||||||
|
|
||||||
|
return web.json_response(
|
||||||
|
{"message": "Nothing to see here", "error": "404"}, status=404
|
||||||
|
)
|
14
src/form/tests.py
Normal file
14
src/form/tests.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
class AppTestCase(unittest.IsolatedAsyncioTestCase):
|
||||||
|
|
||||||
|
async def asyncSetup(self):
|
||||||
|
print("Async setup")
|
||||||
|
|
||||||
|
async def test_init(self):
|
||||||
|
self.assertTrue(True)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
Loading…
Reference in New Issue
Block a user