Proton客户端 is a tool for creating and managing Proton apps, similar to Proton.js but with some improvements. It is built on Proton.js and provides a more secure and feature-rich alternative.
Here's a concise guide to setting up Proton客户端:
Step 1: Install the Proton客户端 CLI
First, install Proton客户端 using pip:
pip install protonclient
Step 2: Configure the Proton App
Create a new Proton app using Proton客户端. Here's an example command:
python -c "from protonclient import ProtonApp; app = ProtonApp()"
Step 3: Configure the App
You need to configure the Proton app with your Proton app setup. Here's an example:
python -c "from protonclient import Config; config = Config() from __init__.py Config.__init__().app_url = 'https://localhost:4'; Config.__init__().node_modules = ['nodejs', 'express', 'protonapp']"
Step 4: Create a New Proton App
Create a new Proton app:
python -c "from protonclient import App; app = App()"
Step 5: Start the App
Start the Proton app:
python -c "from protonclient import App; app = App() from protonclient import Server; server = Server(app); server.start()"
Important Notes:
- The Proton app requires a custom module for routing. You need to create a
routing.pyfile in your Proton app and add the following to it:
from protonclient import routing
app = routing.App('app_name')
app.module.add('routing', routing.Routing('routing.py'))
- The Proton app should not be submitted to the internet, as Proton.js is not secure.
Example of a Simple Proton App
Here's an example of a basic Proton app using Proton客户端:
from protonclient import App
from protonclient import Server
app = App()
app.module.add('routing', routing.Routing('routing.py'))
server = Server(app)
server.start()
from protonclient import Route
route = Route('my_route')
route destinations = ['http://localhost:8', 'https://localhost:81']
app.module.add('routes', route)
app.start()
This example creates a simple Proton app that routes to two different URLs.
Summary
- Install Proton客户端 using pip.
- Configure the Proton app with your Proton app setup.
- Create and start a Proton app using Proton客户端.
- Customize the app as needed and add routes.
Remember to keep your Proton app secure and not submit it to the internet to avoid security risks.




