hyperflask 0.4.0__tar.gz → 0.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. {hyperflask-0.4.0 → hyperflask-0.4.1}/PKG-INFO +2 -3
  2. {hyperflask-0.4.0 → hyperflask-0.4.1}/README.md +0 -1
  3. {hyperflask-0.4.0 → hyperflask-0.4.1}/pyproject.toml +2 -2
  4. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/app.py +33 -1
  5. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/cli/runner.py +19 -6
  6. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/factory.py +5 -10
  7. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/__init__.py +0 -0
  8. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/__main__.py +0 -0
  9. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/actors.py +0 -0
  10. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/cli/__init__.py +0 -0
  11. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/cli/reloader.py +0 -0
  12. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/cli/worker.py +0 -0
  13. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/components/__init__.py +0 -0
  14. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/components/alpine.py +0 -0
  15. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/components/core.py +0 -0
  16. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/components/jsx.py +0 -0
  17. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/components/webcomponent.py +0 -0
  18. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/forms/__init__.py +0 -0
  19. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/forms/fields.py +0 -0
  20. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/forms/widgets.py +0 -0
  21. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/layouts/email.mjml +0 -0
  22. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/layouts/web.html +0 -0
  23. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/model.py +0 -0
  24. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/page_helpers.py +0 -0
  25. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/security.py +0 -0
  26. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/static/alpine-csp.js +0 -0
  27. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/static/alpine.js +0 -0
  28. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/static/app.css +0 -0
  29. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/static/app.js +0 -0
  30. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/static/htmx-exts.js +0 -0
  31. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/static/react.js +0 -0
  32. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/static/stimulus.js +0 -0
  33. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/static/translations.js +0 -0
  34. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Accordion.html +0 -0
  35. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/AccordionPanel.html +0 -0
  36. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Alert.html +0 -0
  37. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Avatar.html +0 -0
  38. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/AvatarGroup.html +0 -0
  39. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Badge.html +0 -0
  40. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Breadcrumbs.html +0 -0
  41. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/BreadcrumbsItem.html +0 -0
  42. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Button.html +0 -0
  43. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Card.html +0 -0
  44. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/CardActions.html +0 -0
  45. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/CardTitle.html +0 -0
  46. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/ChatBubble.html +0 -0
  47. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Checkbox.html +0 -0
  48. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/CollapsibleSubMenu.html +0 -0
  49. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Countdown.html +0 -0
  50. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Divider.html +0 -0
  51. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Drawer.html +0 -0
  52. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/DrawerContent.html +0 -0
  53. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/DrawerSide.html +0 -0
  54. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Dropdown.html +0 -0
  55. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/DropdownItem.html +0 -0
  56. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Fieldset.html +0 -0
  57. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/FieldsetLegend.html +0 -0
  58. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/FileInput.html +0 -0
  59. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Filter.html +0 -0
  60. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/FilterItem.html +0 -0
  61. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Footer.html +0 -0
  62. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/FooterLink.html +0 -0
  63. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/FooterNav.html +0 -0
  64. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Indicator.html +0 -0
  65. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Input.html +0 -0
  66. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/InputLabel.html +0 -0
  67. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Join.html +0 -0
  68. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Kbd.html +0 -0
  69. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Label.html +0 -0
  70. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/LabeledCheckbox.html +0 -0
  71. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/LabeledToggle.html +0 -0
  72. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Link.html +0 -0
  73. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/List.html +0 -0
  74. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/ListItem.html +0 -0
  75. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Loading.html +0 -0
  76. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Menu.html +0 -0
  77. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/MenuItem.html +0 -0
  78. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/MenuTitle.html +0 -0
  79. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Modal.html +0 -0
  80. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/ModalAction.html +0 -0
  81. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/ModalTitle.html +0 -0
  82. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Navbar.html +0 -0
  83. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Pagination.html +0 -0
  84. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/PaginationNext.html +0 -0
  85. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/PaginationPage.html +0 -0
  86. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/PaginationPrev.html +0 -0
  87. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Progress.html +0 -0
  88. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/README.md +0 -0
  89. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Radio.html +0 -0
  90. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Range.html +0 -0
  91. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Rating.html +0 -0
  92. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Select.html +0 -0
  93. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Stack.html +0 -0
  94. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Stat.html +0 -0
  95. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Stats.html +0 -0
  96. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Step.html +0 -0
  97. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Steps.html +0 -0
  98. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/SubMenu.html +0 -0
  99. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Swap.html +0 -0
  100. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Tab.html +0 -0
  101. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Table.html +0 -0
  102. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Tabs.html +0 -0
  103. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Textarea.html +0 -0
  104. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Toast.html +0 -0
  105. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Toggle.html +0 -0
  106. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/daisyui/Tooltip.html +0 -0
  107. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/flash.html +0 -0
  108. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/forms.html +0 -0
  109. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/icons.html +0 -0
  110. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/layout.html +0 -0
  111. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/modal.html +0 -0
  112. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/skeleton.html +0 -0
  113. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/ui/sse.html +0 -0
  114. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/utils/__init__.py +0 -0
  115. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/utils/html.py +0 -0
  116. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/utils/htmx.py +0 -0
  117. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/utils/markdown.py +0 -0
  118. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/utils/metadata.py +0 -0
  119. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/utils/page_actions.py +0 -0
  120. {hyperflask-0.4.0 → hyperflask-0.4.1}/src/hyperflask/utils/tokens.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyperflask
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary: Full stack web framework
5
5
  Author: Maxime Bouroumeau-Fuseau
6
6
  Author-email: Maxime Bouroumeau-Fuseau <maxime.bouroumeau@gmail.com>
@@ -15,7 +15,7 @@ Requires-Dist: flask-file-routes~=0.3
15
15
  Requires-Dist: flask-files~=0.2
16
16
  Requires-Dist: flask-geo~=0.1
17
17
  Requires-Dist: flask-mailman-templates~=0.1
18
- Requires-Dist: flask-mercure-sse~=0.3
18
+ Requires-Dist: flask-mercure-sse~=0.4
19
19
  Requires-Dist: flask-sqlorm~=0.3
20
20
  Requires-Dist: flask-super-macros~=0.2
21
21
  Requires-Dist: flask-suspense~=0.3
@@ -96,7 +96,6 @@ A good part of these extensions is developed as part of the Hyperflask project.
96
96
  | [Flask-Collections](https://github.com/hyperflask/flask-collections) | Manage collections of static content
97
97
  | [Flask-Configurator](https://github.com/hyperflask/flask-configurator) | File based configuration
98
98
  | [Flask-DebugToolbar](https://github.com/pallets-eco/flask-debugtoolbar) | Debug Toolbar
99
- | [Flask-Dramatiq](https://flask-dramatiq.readthedocs.io) | Background tasks powered by [Dramatiq](https://dramatiq.io/) |
100
99
  | [Flask-File-Routes](https://github.com/hyperflask/flask-file-routes) | File-based routing with a new file format combining python and jinja template in a single file
101
100
  | [Flask-Files](https://github.com/hyperflask/flask-files) | [Fsspec](https://filesystem-spec.readthedocs.io/en/latest/) based files management (upload, storage and image manipulation)
102
101
  | [Frozen-Flask](https://github.com/Frozen-Flask/Frozen) | Generate a static website from your Flask app |
@@ -58,7 +58,6 @@ A good part of these extensions is developed as part of the Hyperflask project.
58
58
  | [Flask-Collections](https://github.com/hyperflask/flask-collections) | Manage collections of static content
59
59
  | [Flask-Configurator](https://github.com/hyperflask/flask-configurator) | File based configuration
60
60
  | [Flask-DebugToolbar](https://github.com/pallets-eco/flask-debugtoolbar) | Debug Toolbar
61
- | [Flask-Dramatiq](https://flask-dramatiq.readthedocs.io) | Background tasks powered by [Dramatiq](https://dramatiq.io/) |
62
61
  | [Flask-File-Routes](https://github.com/hyperflask/flask-file-routes) | File-based routing with a new file format combining python and jinja template in a single file
63
62
  | [Flask-Files](https://github.com/hyperflask/flask-files) | [Fsspec](https://filesystem-spec.readthedocs.io/en/latest/) based files management (upload, storage and image manipulation)
64
63
  | [Frozen-Flask](https://github.com/Frozen-Flask/Frozen) | Generate a static website from your Flask app |
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "hyperflask"
3
- version = "0.4.0"
3
+ version = "0.4.1"
4
4
  description = "Full stack web framework"
5
5
  authors = [
6
6
  {"name" = "Maxime Bouroumeau-Fuseau", email = "maxime.bouroumeau@gmail.com"}
@@ -19,7 +19,7 @@ dependencies = [
19
19
  "flask-files ~=0.2",
20
20
  "flask-geo ~=0.1",
21
21
  "flask-mailman-templates ~=0.1",
22
- "flask-mercure-sse ~=0.3",
22
+ "flask-mercure-sse ~=0.4",
23
23
  #"flask-observability ~=0.1"
24
24
  "flask-sqlorm ~=0.3",
25
25
  "flask-super-macros ~=0.2",
@@ -1,5 +1,5 @@
1
1
  # flask
2
- from flask import Flask
2
+ from flask import Flask, has_request_context, request
3
3
  from jinja2 import ChoiceLoader, FileSystemLoader, PrefixLoader, TemplateNotFound
4
4
  from werkzeug.middleware.proxy_fix import ProxyFix
5
5
  # hyperflask extensions
@@ -73,6 +73,7 @@ class Hyperflask(Flask):
73
73
  "SESSION_COOKIE_SAMESITE": "Lax",
74
74
  "SQLORM_URI": database_uri,
75
75
  # Hyperflask specific
76
+ "URL_FOR_SERVER_NAME": None,
76
77
  "LAYOUT": "layouts/default.html",
77
78
  "ALPINE": False,
78
79
  "STATIC_MODE": static_mode,
@@ -113,6 +114,9 @@ class Hyperflask(Flask):
113
114
  })
114
115
  self.config.setdefault("HSTS_HEADER", "max-age=31556926; includeSubDomains") # 1 year
115
116
 
117
+ if (self.config['URL_FOR_SERVER_NAME'] or self.config.get('SERVER_NAME')) and not self.config.get('MERCURE_HUB_URL') and not self.config.get('MERCURE_PUBLIC_HUB_URL'):
118
+ self.config['MERCURE_PUBLIC_HUB_URL'] = True
119
+
116
120
  #self.otel = Observability(self)
117
121
 
118
122
  self.jinja_env.add_extension(LayoutExtension)
@@ -247,6 +251,34 @@ class Hyperflask(Flask):
247
251
  def relative_import_name(self, name):
248
252
  return f"{self.import_name}.{name}" if self.import_name != "__main__" else name
249
253
 
254
+ @property
255
+ def base_url(self):
256
+ scheme = self.config.get('PREFERRED_URL_SCHEME', 'http')
257
+ if self.config.get('SERVER_NAME'):
258
+ return f"{scheme}://{self.config['SERVER_NAME']}"
259
+ if self.config['URL_FOR_SERVER_NAME']:
260
+ return f"{scheme}://{self.config['URL_FOR_SERVER_NAME']}"
261
+ if has_request_context():
262
+ return request.host_url
263
+ raise RuntimeError("No request context and no SERVER_NAME or URL_FOR_SERVER_NAME configured, cannot determine base_url")
264
+
265
+ def url_for(self, *args, **kwargs):
266
+ _external = kwargs.get("_external", False)
267
+ _scheme = kwargs.get("_scheme", None)
268
+ if _external and self.config['URL_FOR_SERVER_NAME']:
269
+ # we handle the host and scheme ourselves
270
+ kwargs['_external'] = False
271
+ kwargs.pop('_scheme', None)
272
+ else:
273
+ _external = False
274
+ url = super().url_for(*args, **kwargs)
275
+ if not _external:
276
+ return url
277
+ if not _scheme:
278
+ _scheme = self.config.get('PREFERRED_URL_SCHEME', 'http')
279
+ url = f"{_scheme}://{self.config['URL_FOR_SERVER_NAME']}{url}"
280
+ return url
281
+
250
282
 
251
283
  class HyperModuleView(ModuleView):
252
284
  module_globals = dict(ModuleView.module_globals, asset_url=asset_url, static_url=static_url)
@@ -4,6 +4,7 @@ import os
4
4
  import sys
5
5
  import multiprocessing
6
6
  import gunicorn.app.base
7
+ from subprocess import Popen
7
8
  from honcho.manager import Manager as BaseProcessManager
8
9
  from ..factory import load_config
9
10
  from . import reloader # import hacky patch of werkzeug reloader
@@ -21,8 +22,6 @@ def serve_command(ctx, info, host, port, gunicorn_opt, **run_kwargs):
21
22
  'proc_name': 'hyperflask',
22
23
  'bind': f'{host}:{port}',
23
24
  'workers': 1 + multiprocessing.cpu_count() * 2,
24
- 'accesslog': '-',
25
- 'errorlog': '-',
26
25
  'max_requests': 1000,
27
26
  'max_requests_jitter': 100
28
27
  }
@@ -41,8 +40,9 @@ serve_command.params = flask_run_command.params + serve_command.params
41
40
  @click.option("--port", "-p", default=5000, help="The port to bind to.")
42
41
  @click.option('--concurrency')
43
42
  @click.option("--extend-procfile")
43
+ @click.option("--init-db/--no-init-db", is_flag=True, default=None)
44
44
  @click.option("--dev", is_flag=True)
45
- def run_command(processes, host, port, concurrency, extend_procfile, dev):
45
+ def run_command(processes, host, port, concurrency, extend_procfile, init_db, dev):
46
46
  from honcho.command import _procfile, _parse_concurrency
47
47
  from honcho.printer import Printer
48
48
  from honcho import environ
@@ -50,6 +50,10 @@ def run_command(processes, host, port, concurrency, extend_procfile, dev):
50
50
  if dev:
51
51
  os.environ["FLASK_DEBUG"] = "1"
52
52
 
53
+ if init_db is None and dev or init_db:
54
+ print("Initializing database...")
55
+ Popen([sys.argv[0], "db", "init"]).wait()
56
+
53
57
  _processes = None
54
58
  config = load_config()
55
59
  for filename in [f"Procfile.{config['ENV']}", "Procfile"]:
@@ -69,9 +73,19 @@ def run_command(processes, host, port, concurrency, extend_procfile, dev):
69
73
  _processes["worker"].extend(["-p", "1", "-t", "1"])
70
74
  else:
71
75
  _processes["mercurehub"] = [sys.executable, "-m", "flask_mercure_sse.server"]
76
+ subscriber_secret_key = config.get("MERCURE_SUBSCRIBER_SECRET_KEY", config.get('SECRET_KEY'))
77
+ if subscriber_secret_key:
78
+ _processes["mercurehub"].extend(["--subscriber-secret", subscriber_secret_key])
79
+ else:
80
+ print("Warning: No MERCURE_SUBSCRIBER_SECRET_KEY or SECRET_KEY set, Mercure subscriber will not be authenticated.")
81
+ publisher_secret_key = config.get("MERCURE_PUBLISHER_SECRET_KEY", config.get('SECRET_KEY'))
82
+ if publisher_secret_key:
83
+ _processes["mercurehub"].extend(["--publisher-secret", publisher_secret_key])
84
+ else:
85
+ print("Warning: No MERCURE_PUBLISHER_SECRET_KEY or SECRET_KEY set, cannot publish Mercure messages.")
72
86
 
73
87
  processes = {name: " ".join(_processes[name]) if isinstance(_processes[name], list) else _processes[name]
74
- for name in _processes if name in _processes}
88
+ for name in _processes if not processes or name in processes}
75
89
 
76
90
  manager = ProcessManager(Printer(sys.stdout, colour=True))
77
91
 
@@ -80,10 +94,9 @@ def run_command(processes, host, port, concurrency, extend_procfile, dev):
80
94
  port=port):
81
95
  e = os.environ.copy()
82
96
  e.update(p.env)
83
- if p.name != "scheduler":
84
- e["FLASK_SKIP_DB_INIT"] = "0"
85
97
  manager.add_process(p.name, p.cmd, quiet=p.quiet, env=e)
86
98
 
99
+ print("Starting Hyperflask processes...")
87
100
  manager.loop()
88
101
  sys.exit(manager.returncode)
89
102
 
@@ -4,7 +4,7 @@ from importlib.metadata import entry_points
4
4
  import logging
5
5
  import os
6
6
  from .app import Hyperflask
7
- from .model import init_db_locked
7
+
8
8
 
9
9
  app = None
10
10
  db = None
@@ -13,9 +13,7 @@ db = None
13
13
  def load_config(root_path=None):
14
14
  debug = os.environ.get("FLASK_DEBUG") == "1"
15
15
  default_env = "development" if debug else "production"
16
- config = Config(root_path, defaults={
17
- "SQLORM_URI": "sqlite://app.db"
18
- })
16
+ config = Config(root_path)
19
17
  config.load("config.yml", default_env)
20
18
  if config["ENV"] == "development" and not config.get("SECRET_KEY"):
21
19
  logging.getLogger().warn("Missing SECRET_KEY has been automatically set to 'changeme' while in development mode")
@@ -41,8 +39,8 @@ def create_app(root_path=None):
41
39
  else:
42
40
  import_name = "__main__"
43
41
 
44
- app = Hyperflask(import_name, root_path=root_path, config=config, static_folder=static_folder,
45
- static_url_path=config.get("STATIC_URL_PATH", "/static"),
42
+ app = Hyperflask(import_name, root_path=root_path, config_filename=None, config=config,
43
+ static_folder=static_folder, static_url_path=config.get("STATIC_URL_PATH", "/static"),
46
44
  migrations_folder=migrations_folder)
47
45
 
48
46
  db = app.db
@@ -60,7 +58,7 @@ def create_app(root_path=None):
60
58
  m = importlib.import_module(module)
61
59
  getattr(m, class_name)(app, **config)
62
60
 
63
- models = try_import(app, "models")
61
+ try_import(app, "models")
64
62
  try_import(app, "routes")
65
63
  try_import(app, "actors")
66
64
  try_import(app, "tasks")
@@ -69,9 +67,6 @@ def create_app(root_path=None):
69
67
  try_import(app, "signals")
70
68
  try_import(app, "app")
71
69
 
72
- if models and app.config.get("INIT_DATABASE", True):
73
- init_db_locked(app)
74
-
75
70
  return app
76
71
 
77
72