def run_routine(): thread = Thread(target=routine, daemon=True) thread.start() class WebAppHandler(RequestHandler): def get(self): self.render('../web-app/dist/index.html') if __name__ == '__main__': crontab('0 0 * * *', func=run_routine, start=True) IOLoop.current().add_callback(setup) main( [(r"/user/?", "handlers.UserInfoHandler"), (r"/login/?", "handlers.LoginHandler"), (r"/oauth", "handlers.GithubLoginHandler"), (r"/logout/?", "handlers.LogoutHandler"), (r'/sitemap.xml()', "tornado.web.StaticFileHandler", { 'path': '../web-app/dist/sitemap.xml' }), (r"/((?:img|css|js|fonts)/.*)", "tornado.web.StaticFileHandler", { "path": "../web-app/dist/" })], { "default_handler_class": WebAppHandler, "static_path": "../web-app/dist/", }, use_curl=True)
from tornado.web import StaticFileHandler, RedirectHandler from biothings.web.index_base import main from web.beacon.handlers import BeaconHandler, BeaconInfoHandler if __name__ == "__main__": main([ (r"/", RedirectHandler, { "url": "/standalone", "permanent": False }), # override default frontpage (r"/demo/?()", StaticFileHandler, { "path": "docs/demo", "default_filename": "index.html" }), (r"/standalone/?()", StaticFileHandler, { "path": "docs/standalone", "default_filename": "index.html" }), (r"/beacon/query?", BeaconHandler), (r"/beacon/info", BeaconInfoHandler), ])
>>> python index.py >>> python index.py --debug >>> python index.py --port=8000 """ import os.path import config from biothings.web.index_base import main ADDON_HANDLERS = [ (r"/demo/?(.*)", "tornado.web.StaticFileHandler", { "path": "docs/demo", "default_filename": "index.html" }), ] if config.INCLUDE_DOCS: if not os.path.exists(config.DOCS_STATIC_PATH): raise IOError('Run "make html" to generate sphinx docs first.') ADDON_HANDLERS += [ (r"/widget/(.*)", "tornado.web.RedirectHandler", { "url": "/static/widget/{0}" }), (r"/?(.*)", "tornado.web.StaticFileHandler", { 'path': config.DOCS_STATIC_PATH }), ] if __name__ == '__main__': main(ADDON_HANDLERS)
from biothings.web.index_base import main if __name__ == "__main__": main()
import os # Instantiate settings class to configure biothings web web_settings = MyGeneWebSettings(config='config') if web_settings.INCLUDE_DOCS and not os.path.exists( web_settings.DOCS_STATIC_PATH): raise IOError('Run "make html" to generate sphinx docs first.') APP_LIST = web_settings.generate_app_list() if options.debug: APP_LIST += [ (r"/widget/(.*)", StaticFileHandler, { 'path': os.path.join(web_settings.STATIC_PATH, 'widget') }), (r"/?(.*)", StaticFileHandler, { 'path': web_settings.DOCS_STATIC_PATH }), ] if __name__ == '__main__': # set debug level on app settings web_settings.set_debug_level(options.debug) main(APP_LIST, debug_settings={ "static_path": web_settings.STATIC_PATH, "debug": True }, sentry_client_key=web_settings.SENTRY_CLIENT_KEY)
from biothings.web.index_base import main from biothings.web.settings import BiothingESWebSettings WEB_SETTINGS = BiothingESWebSettings(config=config) def schedule_daily_job(): tomorrow = datetime.datetime.today() + datetime.timedelta(days=1) midnight = datetime.datetime.combine(tomorrow, datetime.time.min) IOLoop.current().add_timeout(midnight.timestamp(), daily_job) def daily_job(): def sync_job(): backup_and_refresh() update_uptime_status() IOLoop.current().run_in_executor(None, sync_job) schedule_daily_job() if __name__ == '__main__': (SRC_PATH, _) = os.path.split(os.path.abspath(__file__)) STATIC_PATH = os.path.join(SRC_PATH, 'static') # IOLoop.current().add_callback(daily_job) # run upon start schedule_daily_job() main(WEB_SETTINGS.generate_app_list(), app_settings={"cookie_secret": config.COOKIE_SECRET}, debug_settings={"static_path": STATIC_PATH}, use_curl=True)
# -*- coding: utf-8 -*- # Simple template example used to instantiate a new biothing API from biothings.web.index_base import main, options from web.settings import GenericFarmWebSettings # Instantiate settings class to configure biothings web web_settings = GenericFarmWebSettings(config='config') if __name__ == '__main__': # set debug level on app settings web_settings.set_debug_level(options.debug) app_list = web_settings.generate_app_list() main(app_list, debug_settings={"debug": True}, sentry_client_key=None)
# -*- coding: utf-8 -*- # Simple template example used to instantiate a new biothing API from biothings.web.index_base import main, options from web.settings import MySpeciesWebSettings # Instantiate settings class to configure biothings web web_settings = MySpeciesWebSettings(config='config') if __name__ == '__main__': # set debug level on app settings web_settings.set_debug_level(options.debug) main(web_settings.generate_app_list(), debug_settings={"STATIC_PATH": web_settings.STATIC_PATH}, sentry_client_key=web_settings.SENTRY_CLIENT_KEY)
from biothings.web.index_base import main, options from biothings.web.settings import BiothingESWebSettings import os.path import config web_settings = BiothingESWebSettings(config=config) if __name__ == '__main__': (src_path, _) = os.path.split(os.path.abspath(__file__)) static_path = os.path.join(src_path, 'static') main(web_settings.generate_app_list(), app_settings={"cookie_secret": config.COOKIE_SECRET}, debug_settings={"static_path": static_path}, use_curl=True)
# -*- coding: utf-8 -*- # Simple template example used to instantiate a new biothing API from biothings.web.index_base import main, options from web.settings import MyDrugWebSettings # Instantiate settings class to configure biothings web web_settings = MyDrugWebSettings(config='config') if __name__ == '__main__': # set debug level on app settings web_settings.set_debug_level(options.debug) main(web_settings.generate_app_list(), debug_settings={"STATIC_PATH": web_settings.STATIC_PATH, "debug": True}, sentry_client_key=web_settings.SENTRY_CLIENT_KEY)
''' Biothings Crawler API Server ''' from biothings.web.index_base import main from web.handlers import MainHandler if __name__ == '__main__': main([ (r'/', MainHandler), ])
from tornado.web import RedirectHandler from biothings.web.index_base import main from web.handlers import MainHandler, ApiViewHandler, SpecialHandler from web.handlers.genomics import routes as genomics_routes if __name__ == '__main__': app_handlers = [ *genomics_routes, (r"/", MainHandler), (r"/v1/(.*)", RedirectHandler, {"url": "/covid19/{0}"}), (r"/try-by-doctype/resources/?", SpecialHandler), (r"/try/.+", ApiViewHandler), (r"/try/.+/.+", ApiViewHandler) ] main(app_handlers=app_handlers) # additionals
''' Tornado Web Server Starting Script - Application Entry Point ''' from threading import Thread from aiocron import crontab from biothings.web.index_base import main from discovery.web.handlers import WEB_HANDLERS, TemplateHandler from discovery.web.notify import update_n3c_routine def run_routine(): thread = Thread(target=update_n3c_routine, daemon=True) thread.start() if __name__ == '__main__': crontab('0 0 * * *', func=run_routine, start=True) main(WEB_HANDLERS, { "default_handler_class": TemplateHandler, "default_handler_args": { "filename": "404.html", "status_code": 404 } }, use_curl=True)
""" https://pending.biothings.io/ https://biothings.ncats.io/ """ from biothings.web.index_base import main from web.handlers import EXTRA_HANDLERS if __name__ == "__main__": main(EXTRA_HANDLERS)
''' Tornado Web Server Starting Script - Application Entry Point ''' import logging import os from biothings.web.index_base import main from discovery.web.settings import DiscoveryWebSettings WEB_SETTINGS = DiscoveryWebSettings(config='config') SRC_PATH = os.path.dirname(os.path.abspath(__file__)) STATIC_PATH = os.path.join(SRC_PATH, 'web', 'static') if __name__ == '__main__': logging.captureWarnings(True) main( WEB_SETTINGS.generate_app_list(), app_settings={ "autoreload": True }, debug_settings={ "static_path": STATIC_PATH }, use_curl=True )