This commit is contained in:
yumoqing 2026-01-27 17:21:57 +08:00
parent 40f46577b0
commit 223ada2bc9
3 changed files with 21 additions and 7 deletions

View File

@ -45,15 +45,30 @@ see requirements.txt
[sqlor](https://github.com/yumoqing/sqlor)
## How to use
see ah.py
## Usage
```
from ahserver.configuredServer import ConfiguredServer
import asyncio
from ahserver.webapp import webapp
from ahserver.configuredServer import add_startup
# task running all the time in background
async def bgwork(app) -> None:
while True:
asyncio.sleep(sec)
print('hahaha')
def get_module_dbname(modulename):
return 'test'
def init():
env = ServerEnv()
# add background task
add_startup(bgwork(10))
env.get_module_dbname = get_module_dbname
if __name__ == '__main__':
server = ConfiguredServer()
server.run()
webapp(init)
```
## Folder structure

View File

@ -130,3 +130,4 @@ class ConfiguredServer:
processors=config.website.processors)
self.app.router.register_resource(res)

View File

@ -38,7 +38,6 @@ from openpyxl import Workbook
from tempfile import mktemp
from appPublic.jsonConfig import getConfig
from appPublic.myTE import string_template_render
from appPublic.dictObject import DictObject
from appPublic.Singleton import GlobalEnv
from appPublic.argsConvert import ArgsConvert
@ -323,7 +322,6 @@ def initEnv():
g.StreamHttpClient = StreamHttpClient
g.server_error = server_error
g.FileStorage = FileStorage
g.str_tmpl_render = string_template_render
g.downloadfile2url = downloadfile2url
g.background_reco = background_reco
g.get_sor_context = get_sor_context