plash-cli 0.3.14__tar.gz → 0.3.16__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.
- plash_cli-0.3.16/PKG-INFO +176 -0
- plash_cli-0.3.16/README.md +149 -0
- plash_cli-0.3.16/plash_cli/__init__.py +2 -0
- {plash_cli-0.3.14 → plash_cli-0.3.16}/plash_cli/_bash_magic.py +5 -4
- plash_cli-0.3.16/plash_cli/_modidx.py +61 -0
- {plash_cli-0.3.14 → plash_cli-0.3.16}/plash_cli/auth.py +12 -12
- {plash_cli-0.3.14 → plash_cli-0.3.16}/plash_cli/cli.py +44 -46
- plash_cli-0.3.16/plash_cli.egg-info/PKG-INFO +176 -0
- {plash_cli-0.3.14 → plash_cli-0.3.16}/plash_cli.egg-info/entry_points.txt +1 -1
- {plash_cli-0.3.14 → plash_cli-0.3.16}/plash_cli.egg-info/requires.txt +3 -3
- {plash_cli-0.3.14 → plash_cli-0.3.16}/pyproject.toml +40 -12
- plash_cli-0.3.14/PKG-INFO +0 -192
- plash_cli-0.3.14/README.md +0 -165
- plash_cli-0.3.14/plash_cli/__init__.py +0 -2
- plash_cli-0.3.14/plash_cli/_modidx.py +0 -41
- plash_cli-0.3.14/plash_cli.egg-info/PKG-INFO +0 -192
- {plash_cli-0.3.14 → plash_cli-0.3.16}/LICENSE +0 -0
- {plash_cli-0.3.14 → plash_cli-0.3.16}/MANIFEST.in +0 -0
- {plash_cli-0.3.14 → plash_cli-0.3.16}/plash_cli/assets/es256_public_key.pem +0 -0
- {plash_cli-0.3.14 → plash_cli-0.3.16}/plash_cli.egg-info/SOURCES.txt +0 -0
- {plash_cli-0.3.14 → plash_cli-0.3.16}/plash_cli.egg-info/dependency_links.txt +0 -0
- {plash_cli-0.3.14 → plash_cli-0.3.16}/plash_cli.egg-info/top_level.txt +0 -0
- {plash_cli-0.3.14 → plash_cli-0.3.16}/setup.cfg +0 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: plash_cli
|
|
3
|
+
Version: 0.3.16
|
|
4
|
+
Summary: CLI for the Plash hosting service
|
|
5
|
+
Author-email: Jeremy Howard <info@fast.ai>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Repository, https://github.com/AnswerDotAI/plash_cli
|
|
8
|
+
Project-URL: Documentation, https://AnswerDotAI.github.io/plash_cli
|
|
9
|
+
Keywords: nbdev,jupyter,notebook,python
|
|
10
|
+
Classifier: Natural Language :: English
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: fastcore>=2.2.20
|
|
19
|
+
Requires-Dist: httpx2
|
|
20
|
+
Requires-Dist: python-dotenv
|
|
21
|
+
Requires-Dist: pyjwt
|
|
22
|
+
Requires-Dist: cryptography
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: bash_kernel; extra == "dev"
|
|
25
|
+
Requires-Dist: fastship; extra == "dev"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# Plash
|
|
29
|
+
|
|
30
|
+
Deploy your python apps in seconds. Fast, reliable, and effortless hosting for developers who want to focus on building, not deploying.
|
|
31
|
+
|
|
32
|
+
> [!WARNING]
|
|
33
|
+
> Plash is in Beta and we have released it in its semi-stable state to gather early feedback to improve. We do not recommend hosting critical applications yet.
|
|
34
|
+
|
|
35
|
+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
36
|
+
|
|
37
|
+
## What is Plash
|
|
38
|
+
|
|
39
|
+
Plash is a next-generation deployment platform for fast, hassle-free Python application hosting. It's designed to be:
|
|
40
|
+
|
|
41
|
+
- **Simple and streamlined** - deploy your applications with minimal configuration
|
|
42
|
+
- **Developer-focused** - built for coders, not cloud engineers
|
|
43
|
+
- **Fast and efficient** - get your app online in seconds, not days
|
|
44
|
+
|
|
45
|
+
Plash handles all the deployment complexities so you can focus on what matters: building great applications. With Plash, you can deploy any Python app using straightforward commands and configurations, letting you ship your work quickly and reliably.
|
|
46
|
+
|
|
47
|
+
Whether you're building web services, APIs, data applications, or tools, Plash provides the infrastructure backbone so you can concentrate on creating a splash with your code.
|
|
48
|
+
|
|
49
|
+
## Tutorial: deploy your first app
|
|
50
|
+
|
|
51
|
+
In this tutorial you will learn how to deploy your first app. This tutorial will explore the basics of using Plash and help you get familiar with it at a high level.
|
|
52
|
+
|
|
53
|
+
**Prerequisites:**
|
|
54
|
+
|
|
55
|
+
- A registered account at [https://pla.sh](https://pla.sh)
|
|
56
|
+
- Basic terminal / command line skills
|
|
57
|
+
|
|
58
|
+
### 1. Installation
|
|
59
|
+
|
|
60
|
+
Install Plash comandline interface (CLI) with pip:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
pip install plash-cli
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The CLI lets you manage your whole app's lifecycle
|
|
67
|
+
|
|
68
|
+
### 2. CLI Login
|
|
69
|
+
|
|
70
|
+
Authenticate with your Plash account:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
plash-login
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
This command opens your browser to authenticate with your Plash account. After completing the login process, you'll see a "complete" confirmation page in your browser.
|
|
77
|
+
|
|
78
|
+
Return to your terminal where you'll find the confirmation message:
|
|
79
|
+
|
|
80
|
+
> Authentication successful! Config saved to /plash\_config.json
|
|
81
|
+
|
|
82
|
+
#### Alternative Authentication Methods
|
|
83
|
+
|
|
84
|
+
If you've already logged in on one machine and want to authenticate on another without opening a browser, you can transfer your authentication token directly. Run `plash-login --show` on the machine where you're already logged in to print your current token. You can then copy this and use `plash-login --token <your-token>` on the new machine to authenticate.
|
|
85
|
+
|
|
86
|
+
For convenience, you can pipe the token directly to your clipboard. On macOS, use `plash-login --show | pbcopy`. On Linux with X11, use `plash-login --show | xclip -selection clipboard` or `plash-login --show | xsel --clipboard`. On Windows PowerShell, use `plash-login --show | Set-Clipboard`.
|
|
87
|
+
|
|
88
|
+
For automated environments like CI/CD pipelines or scripts, you can set the `PLASH_TOKEN` environment variable instead of storing credentials in a config file. When this variable is set, the CLI will use it automatically without requiring `plash-login`. For example: `export PLASH_TOKEN="your-authentication-token"` on Unix-like systems, or `$env:PLASH_TOKEN="your-authentication-token"` in PowerShell.
|
|
89
|
+
|
|
90
|
+
### 3. Create your first app
|
|
91
|
+
|
|
92
|
+
Create a new directory for your first app:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
%%bash
|
|
96
|
+
mkdir -p plash-tutorial
|
|
97
|
+
cd plash-tutorial
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Next, create the `main.py` file:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
%%writefile main.py
|
|
104
|
+
from fasthtml.common import *
|
|
105
|
+
|
|
106
|
+
app, rt = fast_app()
|
|
107
|
+
|
|
108
|
+
@rt
|
|
109
|
+
def index():
|
|
110
|
+
return H1("Hello, world!")
|
|
111
|
+
|
|
112
|
+
serve()
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
This is a basic [FastHTML](https://fastht.ml) app. Plash also supports other popular python frameworks.
|
|
116
|
+
|
|
117
|
+
> [!WARNING]
|
|
118
|
+
> Your app must use port 5001, as this is the port exposed by Plash's Docker container. It also happens to be the default for FastHTML apps.
|
|
119
|
+
|
|
120
|
+
And create the `requirements.txt` file:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
%%writefile requirements.txt
|
|
124
|
+
python-fasthtml
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 4. Deploy your app
|
|
128
|
+
|
|
129
|
+
Now that you've created your app files, you're ready to deploy! From your `plash-tutorial` directory, run: `plash-deploy`
|
|
130
|
+
|
|
131
|
+
This command will:
|
|
132
|
+
|
|
133
|
+
1. Package your application files
|
|
134
|
+
2. Upload them to Plash's servers
|
|
135
|
+
3. Build and deploy your application
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
%%bash
|
|
139
|
+
plash-deploy
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
```output
|
|
143
|
+
Initializing deployment...
|
|
144
|
+
✅ Upload complete! Your app is currently being built.
|
|
145
|
+
It will be live at https://example-app.pla.sh
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Note:** You'll see a different url that has been randomly generated for your app.
|
|
149
|
+
|
|
150
|
+
### 5. View your app
|
|
151
|
+
|
|
152
|
+
Your app should be ready a couple of seconds after running the deploy command.
|
|
153
|
+
|
|
154
|
+
Once your app is ready, you can:
|
|
155
|
+
|
|
156
|
+
1. Open the provided URL in your browser, or
|
|
157
|
+
2. Use the convenient plash-view command to open it automatically:
|
|
158
|
+
|
|
159
|
+
```sh
|
|
160
|
+
plash-view
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
When you visit that page you should see "Hello, World!"
|
|
164
|
+
|
|
165
|
+
🎉 Congratulations! You deployed your first app on Plash!
|
|
166
|
+
|
|
167
|
+
## Where to go from here
|
|
168
|
+
|
|
169
|
+
Learn more about what Plash has to offer in the rest of the docs at: [https://docs.pla.sh](https://docs.pla.sh)
|
|
170
|
+
|
|
171
|
+
To learn more about creating web apps with FastHTML, we recommend looking at the official docs at: [https://fastht.ml/docs/](https://fastht.ml/docs/). In particular, we recommend the following:
|
|
172
|
+
|
|
173
|
+
1. [OAuth](https://fastht.ml/docs/explains/oauth.html) - Setup authentication for your Plash App with Google Sign-In or other OAuth Providers.
|
|
174
|
+
2. [Stripe](https://fastht.ml/docs/explains/stripe.html) - Accept payments for your products hosted on Plash with Stripe.
|
|
175
|
+
|
|
176
|
+
Would you like to use a different python web framework? Then check out the [examples section](https://github.com/AnswerDotAI/plash_cli/tree/main/examples) of the repo, it has examples for many popular python web frameworks like FastAPI, Gradio, and Streamlit.
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Plash
|
|
2
|
+
|
|
3
|
+
Deploy your python apps in seconds. Fast, reliable, and effortless hosting for developers who want to focus on building, not deploying.
|
|
4
|
+
|
|
5
|
+
> [!WARNING]
|
|
6
|
+
> Plash is in Beta and we have released it in its semi-stable state to gather early feedback to improve. We do not recommend hosting critical applications yet.
|
|
7
|
+
|
|
8
|
+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
9
|
+
|
|
10
|
+
## What is Plash
|
|
11
|
+
|
|
12
|
+
Plash is a next-generation deployment platform for fast, hassle-free Python application hosting. It's designed to be:
|
|
13
|
+
|
|
14
|
+
- **Simple and streamlined** - deploy your applications with minimal configuration
|
|
15
|
+
- **Developer-focused** - built for coders, not cloud engineers
|
|
16
|
+
- **Fast and efficient** - get your app online in seconds, not days
|
|
17
|
+
|
|
18
|
+
Plash handles all the deployment complexities so you can focus on what matters: building great applications. With Plash, you can deploy any Python app using straightforward commands and configurations, letting you ship your work quickly and reliably.
|
|
19
|
+
|
|
20
|
+
Whether you're building web services, APIs, data applications, or tools, Plash provides the infrastructure backbone so you can concentrate on creating a splash with your code.
|
|
21
|
+
|
|
22
|
+
## Tutorial: deploy your first app
|
|
23
|
+
|
|
24
|
+
In this tutorial you will learn how to deploy your first app. This tutorial will explore the basics of using Plash and help you get familiar with it at a high level.
|
|
25
|
+
|
|
26
|
+
**Prerequisites:**
|
|
27
|
+
|
|
28
|
+
- A registered account at [https://pla.sh](https://pla.sh)
|
|
29
|
+
- Basic terminal / command line skills
|
|
30
|
+
|
|
31
|
+
### 1. Installation
|
|
32
|
+
|
|
33
|
+
Install Plash comandline interface (CLI) with pip:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
pip install plash-cli
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The CLI lets you manage your whole app's lifecycle
|
|
40
|
+
|
|
41
|
+
### 2. CLI Login
|
|
42
|
+
|
|
43
|
+
Authenticate with your Plash account:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
plash-login
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This command opens your browser to authenticate with your Plash account. After completing the login process, you'll see a "complete" confirmation page in your browser.
|
|
50
|
+
|
|
51
|
+
Return to your terminal where you'll find the confirmation message:
|
|
52
|
+
|
|
53
|
+
> Authentication successful! Config saved to /plash\_config.json
|
|
54
|
+
|
|
55
|
+
#### Alternative Authentication Methods
|
|
56
|
+
|
|
57
|
+
If you've already logged in on one machine and want to authenticate on another without opening a browser, you can transfer your authentication token directly. Run `plash-login --show` on the machine where you're already logged in to print your current token. You can then copy this and use `plash-login --token <your-token>` on the new machine to authenticate.
|
|
58
|
+
|
|
59
|
+
For convenience, you can pipe the token directly to your clipboard. On macOS, use `plash-login --show | pbcopy`. On Linux with X11, use `plash-login --show | xclip -selection clipboard` or `plash-login --show | xsel --clipboard`. On Windows PowerShell, use `plash-login --show | Set-Clipboard`.
|
|
60
|
+
|
|
61
|
+
For automated environments like CI/CD pipelines or scripts, you can set the `PLASH_TOKEN` environment variable instead of storing credentials in a config file. When this variable is set, the CLI will use it automatically without requiring `plash-login`. For example: `export PLASH_TOKEN="your-authentication-token"` on Unix-like systems, or `$env:PLASH_TOKEN="your-authentication-token"` in PowerShell.
|
|
62
|
+
|
|
63
|
+
### 3. Create your first app
|
|
64
|
+
|
|
65
|
+
Create a new directory for your first app:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
%%bash
|
|
69
|
+
mkdir -p plash-tutorial
|
|
70
|
+
cd plash-tutorial
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Next, create the `main.py` file:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
%%writefile main.py
|
|
77
|
+
from fasthtml.common import *
|
|
78
|
+
|
|
79
|
+
app, rt = fast_app()
|
|
80
|
+
|
|
81
|
+
@rt
|
|
82
|
+
def index():
|
|
83
|
+
return H1("Hello, world!")
|
|
84
|
+
|
|
85
|
+
serve()
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
This is a basic [FastHTML](https://fastht.ml) app. Plash also supports other popular python frameworks.
|
|
89
|
+
|
|
90
|
+
> [!WARNING]
|
|
91
|
+
> Your app must use port 5001, as this is the port exposed by Plash's Docker container. It also happens to be the default for FastHTML apps.
|
|
92
|
+
|
|
93
|
+
And create the `requirements.txt` file:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
%%writefile requirements.txt
|
|
97
|
+
python-fasthtml
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 4. Deploy your app
|
|
101
|
+
|
|
102
|
+
Now that you've created your app files, you're ready to deploy! From your `plash-tutorial` directory, run: `plash-deploy`
|
|
103
|
+
|
|
104
|
+
This command will:
|
|
105
|
+
|
|
106
|
+
1. Package your application files
|
|
107
|
+
2. Upload them to Plash's servers
|
|
108
|
+
3. Build and deploy your application
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
%%bash
|
|
112
|
+
plash-deploy
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```output
|
|
116
|
+
Initializing deployment...
|
|
117
|
+
✅ Upload complete! Your app is currently being built.
|
|
118
|
+
It will be live at https://example-app.pla.sh
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Note:** You'll see a different url that has been randomly generated for your app.
|
|
122
|
+
|
|
123
|
+
### 5. View your app
|
|
124
|
+
|
|
125
|
+
Your app should be ready a couple of seconds after running the deploy command.
|
|
126
|
+
|
|
127
|
+
Once your app is ready, you can:
|
|
128
|
+
|
|
129
|
+
1. Open the provided URL in your browser, or
|
|
130
|
+
2. Use the convenient plash-view command to open it automatically:
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
plash-view
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
When you visit that page you should see "Hello, World!"
|
|
137
|
+
|
|
138
|
+
🎉 Congratulations! You deployed your first app on Plash!
|
|
139
|
+
|
|
140
|
+
## Where to go from here
|
|
141
|
+
|
|
142
|
+
Learn more about what Plash has to offer in the rest of the docs at: [https://docs.pla.sh](https://docs.pla.sh)
|
|
143
|
+
|
|
144
|
+
To learn more about creating web apps with FastHTML, we recommend looking at the official docs at: [https://fastht.ml/docs/](https://fastht.ml/docs/). In particular, we recommend the following:
|
|
145
|
+
|
|
146
|
+
1. [OAuth](https://fastht.ml/docs/explains/oauth.html) - Setup authentication for your Plash App with Google Sign-In or other OAuth Providers.
|
|
147
|
+
2. [Stripe](https://fastht.ml/docs/explains/stripe.html) - Accept payments for your products hosted on Plash with Stripe.
|
|
148
|
+
|
|
149
|
+
Would you like to use a different python web framework? Then check out the [examples section](https://github.com/AnswerDotAI/plash_cli/tree/main/examples) of the repo, it has examples for many popular python web frameworks like FastAPI, Gradio, and Streamlit.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
from IPython.core.magic import register_line_cell_magic
|
|
2
1
|
from bash_kernel.kernel import BashKernel
|
|
3
2
|
import re
|
|
4
3
|
from pathlib import Path
|
|
@@ -15,15 +14,17 @@ def interpolate_variables(text):
|
|
|
15
14
|
text = text.replace(match.group(0), str(ip.user_ns[varname]))
|
|
16
15
|
return text
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
def bash(line, cell=None):
|
|
17
|
+
def bash(line, cell=None):
|
|
20
18
|
code = f'{line}\n{cell}' if cell else line
|
|
21
19
|
code = interpolate_variables(code)
|
|
22
20
|
print(bk.bashwrapper.run_command(code))
|
|
23
21
|
|
|
24
|
-
@register_line_cell_magic
|
|
25
22
|
def writefile(line, cell):
|
|
26
23
|
cell = interpolate_variables(cell)
|
|
27
24
|
pwd = bk.bashwrapper.run_command('pwd').strip()
|
|
28
25
|
fpath = Path(pwd) / line
|
|
29
26
|
fpath.write_text(cell)
|
|
27
|
+
|
|
28
|
+
if ip:
|
|
29
|
+
ip.register_magic_function(bash, 'line_cell')
|
|
30
|
+
ip.register_magic_function(writefile, 'line_cell')
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Autogenerated by nbdev
|
|
2
|
+
|
|
3
|
+
d = { 'settings': { 'branch': 'main',
|
|
4
|
+
'lib_path': 'plash_cli',
|
|
5
|
+
'git_url': 'https://github.com/AnswerDotAI/plash_cli',
|
|
6
|
+
'doc_host': 'https://AnswerDotAI.github.io',
|
|
7
|
+
'doc_baseurl': '/plash_cli'},
|
|
8
|
+
'syms': { 'plash_cli.auth': { 'plash_cli.auth._signin_url': ('reference/auth.html#_signin_url', 'plash_cli/auth.py'),
|
|
9
|
+
'plash_cli.auth.mk_signin_url': ('reference/auth.html#mk_signin_url', 'plash_cli/auth.py'),
|
|
10
|
+
'plash_cli.auth._parse_jwt': ('reference/auth.html#_parse_jwt', 'plash_cli/auth.py'),
|
|
11
|
+
'plash_cli.auth.PlashAuthError': ('reference/auth.html#plashautherror', 'plash_cli/auth.py'),
|
|
12
|
+
'plash_cli.auth.goog_id_from_signin_reply': ( 'reference/auth.html#goog_id_from_signin_reply',
|
|
13
|
+
'plash_cli/auth.py')},
|
|
14
|
+
'plash_cli.cli': { 'plash_cli.cli._get_client': ('reference/cli.html#_get_client', 'plash_cli/cli.py'),
|
|
15
|
+
'plash_cli.cli._mk_auth_req': ('reference/cli.html#_mk_auth_req', 'plash_cli/cli.py'),
|
|
16
|
+
'plash_cli.cli._get_app_name': ('reference/cli.html#_get_app_name', 'plash_cli/cli.py'),
|
|
17
|
+
'plash_cli.cli._prep': ('reference/cli.html#_prep', 'plash_cli/cli.py'),
|
|
18
|
+
'plash_cli.cli._endpoint': ('reference/cli.html#_endpoint', 'plash_cli/cli.py'),
|
|
19
|
+
'plash_cli.cli._is_included': ('reference/cli.html#_is_included', 'plash_cli/cli.py'),
|
|
20
|
+
'plash_cli.cli.PlashError': ('reference/cli.html#plasherror', 'plash_cli/cli.py'),
|
|
21
|
+
'plash_cli.cli._poll_cookies': ('reference/cli.html#_poll_cookies', 'plash_cli/cli.py'),
|
|
22
|
+
'plash_cli.cli.login': ('reference/cli.html#login', 'plash_cli/cli.py'),
|
|
23
|
+
'plash_cli.cli._deps': ('reference/cli.html#_deps', 'plash_cli/cli.py'),
|
|
24
|
+
'plash_cli.cli._validate_app': ('reference/cli.html#_validate_app', 'plash_cli/cli.py'),
|
|
25
|
+
'plash_cli.cli.create_tar_archive': ('reference/cli.html#create_tar_archive', 'plash_cli/cli.py'),
|
|
26
|
+
'plash_cli.cli.deploy': ('reference/cli.html#deploy', 'plash_cli/cli.py'),
|
|
27
|
+
'plash_cli.cli._deploy': ('reference/cli.html#_deploy', 'plash_cli/cli.py'),
|
|
28
|
+
'plash_cli.cli.view': ('reference/cli.html#view', 'plash_cli/cli.py'),
|
|
29
|
+
'plash_cli.cli.delete_app': ('reference/cli.html#delete_app', 'plash_cli/cli.py'),
|
|
30
|
+
'plash_cli.cli._delete': ('reference/cli.html#_delete', 'plash_cli/cli.py'),
|
|
31
|
+
'plash_cli.cli.start_app': ('reference/cli.html#start_app', 'plash_cli/cli.py'),
|
|
32
|
+
'plash_cli.cli._start': ('reference/cli.html#_start', 'plash_cli/cli.py'),
|
|
33
|
+
'plash_cli.cli.stop_app': ('reference/cli.html#stop_app', 'plash_cli/cli.py'),
|
|
34
|
+
'plash_cli.cli._stop': ('reference/cli.html#_stop', 'plash_cli/cli.py'),
|
|
35
|
+
'plash_cli.cli.logs': ('reference/cli.html#logs', 'plash_cli/cli.py'),
|
|
36
|
+
'plash_cli.cli._logs': ('reference/cli.html#_logs', 'plash_cli/cli.py'),
|
|
37
|
+
'plash_cli.cli.Path._is_dir_empty': ('reference/cli.html#path._is_dir_empty', 'plash_cli/cli.py'),
|
|
38
|
+
'plash_cli.cli.download_app': ('reference/cli.html#download_app', 'plash_cli/cli.py'),
|
|
39
|
+
'plash_cli.cli._download': ('reference/cli.html#_download', 'plash_cli/cli.py'),
|
|
40
|
+
'plash_cli.cli.app_list': ('reference/cli.html#app_list', 'plash_cli/cli.py'),
|
|
41
|
+
'plash_cli.cli._app_list': ('reference/cli.html#_app_list', 'plash_cli/cli.py'),
|
|
42
|
+
'plash_cli.cli.plash_tool_info': ('reference/cli.html#plash_tool_info', 'plash_cli/cli.py')}}}
|
|
43
|
+
|
|
44
|
+
docs = { 'How To': [ ( 'Add Environment Variables',
|
|
45
|
+
'how_to/env_vars.md',
|
|
46
|
+
'Use environment variables to configure your app without changing code. Perfect for secrets, API keys, '
|
|
47
|
+
'and other configuration values.'),
|
|
48
|
+
( 'Add Dependencies',
|
|
49
|
+
'how_to/add_dependencies.md',
|
|
50
|
+
'How to add python and non-python dependencies to your app'),
|
|
51
|
+
('Add Custom Domains', 'how_to/add_custom_domain.md', 'How to add custom domains'),
|
|
52
|
+
('Restore backups', 'how_to/restore_backups.md', "How to restore your app's data"),
|
|
53
|
+
('Auth', 'how_to/auth.md', 'Add Google sign-in to a Plash app')],
|
|
54
|
+
'Explanations': [ ( 'Docker Caching',
|
|
55
|
+
'explains/docker_caching.md',
|
|
56
|
+
'Understanding how our Dockerfile structure is designed to save you valuable development time'),
|
|
57
|
+
('Data Storage', 'explains/data_storage.md', 'Explainer on how Plash deals with data storage'),
|
|
58
|
+
( 'Usage-Based Billing',
|
|
59
|
+
'explains/usage_billing.md',
|
|
60
|
+
'Plash charges you only for the resources your applications actually consume.')],
|
|
61
|
+
'Reference': ['plash_cli.cli', 'plash_cli.auth']}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
"""Client side logic to add Plash Auth to your app
|
|
2
2
|
|
|
3
|
-
Docs: https://AnswerDotAI.github.io/plash_cli/auth.
|
|
3
|
+
Docs: https://AnswerDotAI.github.io/plash_cli/reference/auth.md"""
|
|
4
4
|
|
|
5
|
-
# AUTOGENERATED! DO NOT EDIT! File to edit: ../
|
|
5
|
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../ship/reference/01_auth.ipynb.
|
|
6
6
|
|
|
7
7
|
# %% auto #0
|
|
8
8
|
__all__ = ['signin_completed_rt', 'mk_signin_url', 'PlashAuthError', 'goog_id_from_signin_reply']
|
|
9
9
|
|
|
10
|
-
# %%
|
|
11
|
-
import
|
|
10
|
+
# %% #c6aa552a
|
|
11
|
+
import httpx2,os,jwt
|
|
12
12
|
from pathlib import Path
|
|
13
13
|
from warnings import warn
|
|
14
14
|
|
|
15
15
|
from . import __version__
|
|
16
16
|
|
|
17
|
-
# %%
|
|
17
|
+
# %% #d3504f51
|
|
18
18
|
_in_prod = os.getenv('PLASH_PRODUCTION', '') == '1'
|
|
19
19
|
|
|
20
|
-
# %%
|
|
20
|
+
# %% #e6590075
|
|
21
21
|
def _signin_url(email_re: str=None, hd_re: str=None):
|
|
22
|
-
res =
|
|
22
|
+
res = httpx2.post(os.environ['PLASH_AUTH_URL'], json=dict(email_re=email_re, hd_re=hd_re),
|
|
23
23
|
auth=(os.environ['PLASH_APP_ID'], os.environ['PLASH_APP_SECRET']),
|
|
24
24
|
headers={'X-PLASH-AUTH-VERSION': __version__}).raise_for_status().json()
|
|
25
25
|
if "warning" in res: warn(res.pop('warning'))
|
|
26
26
|
return res
|
|
27
27
|
|
|
28
|
-
# %%
|
|
28
|
+
# %% #4b15411c
|
|
29
29
|
signin_completed_rt = "/signin_completed"
|
|
30
30
|
|
|
31
|
-
# %%
|
|
31
|
+
# %% #74a0a24d
|
|
32
32
|
def mk_signin_url(
|
|
33
33
|
session: dict, # Session dictionary
|
|
34
34
|
email_re: str=None, # Regex filter for allowed email addresses
|
|
@@ -40,7 +40,7 @@ def mk_signin_url(
|
|
|
40
40
|
session['req_id'] = res['req_id']
|
|
41
41
|
return res['plash_signin_url']
|
|
42
42
|
|
|
43
|
-
# %%
|
|
43
|
+
# %% #8e66bb6e
|
|
44
44
|
def _parse_jwt(reply: str) -> dict:
|
|
45
45
|
"Parse JWT reply and return decoded claims or error info"
|
|
46
46
|
try: decoded = jwt.decode(reply, key=open(Path(__file__).parent / "assets" / "es256_public_key.pem","rb").read(), algorithms=["ES256"],
|
|
@@ -48,12 +48,12 @@ def _parse_jwt(reply: str) -> dict:
|
|
|
48
48
|
except Exception as e: return dict(req_id=None, sub=None, err=f'JWT validation failed: {e}')
|
|
49
49
|
return dict(req_id=decoded.get('req_id'), sub=decoded.get('sub'), err=decoded.get('err'))
|
|
50
50
|
|
|
51
|
-
# %%
|
|
51
|
+
# %% #0e61fbdd
|
|
52
52
|
class PlashAuthError(Exception):
|
|
53
53
|
"""Raised when Plash authentication fails"""
|
|
54
54
|
pass
|
|
55
55
|
|
|
56
|
-
# %%
|
|
56
|
+
# %% #a311ce9a
|
|
57
57
|
def goog_id_from_signin_reply(
|
|
58
58
|
session: dict, # Session dictionary containing 'req_id'
|
|
59
59
|
reply: str # The JWT reply string from Plash after Google authentication
|