Skip to content

Commit f174cc9

Browse files
committed
Updated docs
1 parent eda88d6 commit f174cc9

File tree

6 files changed

+106
-316
lines changed

6 files changed

+106
-316
lines changed

docs/getting-started copy.md

Lines changed: 0 additions & 296 deletions
This file was deleted.

docs/getting-started.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ hide: [navigation]
55

66
Welcome to Hyperflask! In this getting started guide will cover the basics and create a simple chat app with authentication.
77

8+
The result of this tutorial is available as a git repository at <https://github.com/hyperflask/getting-started>.
9+
810
## Meet Hyperflask
911

1012
Hyperflask is an opiniated full stack rapid web development framework. It uses Python on the backend, powered by the Flask framework and javascript with htmx on the frontend.
@@ -104,6 +106,8 @@ We are going to create a `ChatMessage` component to render one message. In `app/
104106

105107
```
106108
---
109+
from hyperflask import request
110+
107111
def post():
108112
return {"message": request.form["message"]}
109113
---
@@ -156,6 +160,7 @@ Modify our component to save messages:
156160

157161
```
158162
---
163+
from hyperflask import request
159164
from app.models import db, Message
160165
161166
def post():
@@ -202,12 +207,13 @@ Modify the `ChatMessage` component back to its simpler state:
202207
</{ChatBubble}>
203208
```
204209

205-
Now let's create a new component `PostMessageForm` in `app/components/PostMessageForm.py` that will handle sending messages.
210+
Now let's create a new component `PostMessageForm` in `app/components/PostMessageForm.jpy` that will handle sending messages.
206211

207212
We will also use the a [form](/guides/forms) in this component to easily validate data.
208213

209214
```
210215
---
216+
from hyperflask import page, current_app
211217
from app.models import db, Message
212218
213219
def post():
@@ -244,23 +250,21 @@ page.messages = Message.find_all()
244250
!!! info
245251
The MercureStream component uses the [htmx SSE extension](https://htmx.org/extensions/sse/) to connect to the sse stream
246252

247-
With a total of 33 lines of code, you now have a real-time and persisted chat room!
248-
249253
## Adding authentication
250254

251-
First, let's install the [hyperflask-auth](https://github.com/hyperflask/hyperflask-auth) extension. In a VS Code terminal (while connected to the dev container), execute `uv add hyperflask-auth`.
255+
First, let's install the [hyperflask-users](https://github.com/hyperflask/hyperflask-users) extension. In a VS Code terminal (while connected to the dev container), execute `uv add hyperflask-users`.
252256

253-
As we will not deal with [database migrations]() during this tutorial, delete your existing database: `rm databases/app.db`.
257+
As we will not deal with [database migrations](/guides/models) during this tutorial, delete your existing database: `rm databases/app.db`.
254258

255259
!!! info
256-
Hyperflask-Auth provices login and signup pages as well as everything you need for a professional authentication flow.
260+
Hyperflask-Users provices login and signup pages as well as everything you need for a professional authentication flow and user management.
257261

258262
Let's create a user model and change our existing model to be bound to users:
259263

260264

261265
```py
262266
from hyperflask.factory import db
263-
from hyperflask_auth import UserMixin, UserRelatedMixin
267+
from hyperflask_users import UserMixin, UserRelatedMixin
264268
import datetime
265269

266270
class User(UserMixin, db.Model):
@@ -274,7 +278,7 @@ class Message(UserRelatedMixin, db.Model):
274278
Modify the component `ChatMessage` to display the author:
275279

276280
```
277-
<{ChatBubble header=props.message.user.username}>
281+
<{ChatBubble header=props.message.user.email}>
278282
{{props.message.message|markdown}}
279283
</{ChatBubble}>
280284
```
@@ -285,6 +289,10 @@ Finally, add `page.login_required()` at the top of your page frontmatter to requ
285289

286290
Signup for an account on Fly.io or any VPS provider (eg: Digital Ocean) then run the following command from a VS Code terminal (while connected to the dev container):
287291

288-
hyperflask deploy
292+
uv run hyperflask deploy
293+
294+
Some information will be requested then the deployment will happen automatically. Connect to your domain and voilà!
295+
296+
## Going further
289297

290-
Some information will be requested then the deployment will happen automatically. Connect to your domain and voilà!
298+
Checkout the [Github repository](https://github.com/hyperflask/getting-started) with the result of this tutorial and more. It also includes a nice UI, chat rooms, etc...

0 commit comments

Comments
 (0)