description
Project description
:rocket: App :facepunch:
Install
pip install iapp -U
Usage
- Rest Api
import jieba
from iapp import App
pred1 = lambda **kwargs: kwargs['x'] + kwargs['y']
pred2 = lambda x=1, y=1: x - y
pred3 = lambda text='小米是家不错的公司': jieba.lcut(text)
app = App(verbose=True)
app.add_route("/", pred1, result_key='result')
app.add_route("/f1", pred1, version="1")
app.add_route("/f2", pred2, version="2")
app.add_route("/f3", pred3, version="3")
app.run()
- Scheduler
from iapp.scheduler import Scheduler
def task1(x):
print(x)
import logging
import time
logging.warning(f'Task1: {time.ctime()}')
def task2():
import logging
import time
logging.warning(f'Task2: {time.ctime()}')
def task3():
return 1 / 0
def my_listener(event):
if event.exception:
print(event.traceback)
print('任务出错了!!!!!!')
else:
print('任务照常运行...')
scheduler = Scheduler()
scheduler.add_job(task1, 'interval', seconds=3, args=('定时任务',))
scheduler.add_job(task2, 'interval', seconds=5)
scheduler.add_job(task3, 'interval', seconds=1)
scheduler.add_listener(my_listener)
scheduler.start()
while 1:
pass
TODO
- add logger
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for appzoo-2020.11.5.19.56.38.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bd37e3332de27b8a8c2496f5d447c4b9dfefe9b083981904167773a85ba71e5 |
|
MD5 | 3600ee9c3b8782d62e7b350309e03529 |
|
BLAKE2b-256 | 96f3179fa76e80db1fce0029230a713b9fb6b51b41cfa09d1f9de18699d3cdf4 |
Close
Hashes for appzoo-2020.11.5.19.56.38-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5310de82badcee2e6761e286f3f40080b746ecf14591ecc1139efa066dc20faa |
|
MD5 | 7cdf45a13f78c2a6e3c073624ca88fef |
|
BLAKE2b-256 | fd682e5e17c6d9e81d0e0589d2bb642d5896187745984f71b6da361ff7eb5433 |