You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I copied the code in simple example code to main.py and run the app but got not found
Do you know what I am doing wrong?
Code below
fromfastapiimportFastAPIfromfastapi_amis_admin.admin.settingsimportSettingsfromfastapi_amis_admin.admin.siteimportAdminSitefromdatetimeimportdatefromfastapi_schedulerimportSchedulerAdmin# Create `FastAPI` applicationapp=FastAPI()
# Create `AdminSite` instancesite=AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///amisadmin.db'))
# # Custom timed task scheduler# from apscheduler.schedulers.asyncio import AsyncIOScheduler# from apscheduler.jobstores.redis import RedisJobStore# # Use `RedisJobStore` to create a job store# scheduler = AsyncIOScheduler(jobstores={'default':RedisJobStore(db=2,host="127.0.0.1",port=6379,password="test")})# scheduler = SchedulerAdmin.bind(site,scheduler=scheduler)# Create an instance of the scheduled task scheduler `SchedulerAdmin`scheduler=SchedulerAdmin.bind(site)
# Add scheduled tasks, refer to the official documentation: https://apscheduler.readthedocs.io/en/master/# use when you want to run the job at fixed intervals of time@scheduler.scheduled_job('interval', seconds=60)definterval_task_test():
print('interval task is run...')
# use when you want to run the job periodically at certain time(s) of day@scheduler.scheduled_job('cron', hour=3, minute=30)defcron_task_test():
print('cron task is run...')
# use when you want to run the job just once at a certain point of time@scheduler.scheduled_job('date', run_date=date(2022, 11, 11))defdate_task_test():
print('date task is run...')
@app.on_event("startup")asyncdefstartup():
# Mount the background management systemsite.mount_app(app)
# Start the scheduled task schedulerscheduler.start()
if__name__=='__main__':
importuvicornuvicorn.run(app, debug=True)
The text was updated successfully, but these errors were encountered:
I copied the code in simple example code to main.py and run the app but got not found

Do you know what I am doing wrong?
Code below
The text was updated successfully, but these errors were encountered: