This tutorial shows how to set up a simple client/server application using Phovea.
The name of the example application is "Test" but you can name it as you like of course.
npm install -g yo
npm install -g github:phovea/generator-phovea
Create repository for application. The application repository is the place where the whole application code resides.
git clone https://github.com/<username or organization>/test.git
git clone https://github.com/<username or organization>/test_product.git
cd test
yo phovea:init-app
Application Title: Test
Client Only: N
Add nesessary libraries
Plugin name: test
Description: A simple test application
Leave all other fields as they are (just press Enter)
In package.json, change under dependencies all phovea references to develop branch.
"phovea_core": "0.1.0" -> "phovea_core": "github:phovea/phovea_core#develop"
"phovea_ui": "0.1.0" -> "phovea_ui": "github:phovea/phovea_ui#develop"
git add .
git commit -m "Initial commit"
git push
If you now go to your Github Test repository, you should see the project the project files and a Readme that explains the installation process.
Stay in the test folder and enter following commands:
git checkout -b develop
git commit -m "New development branch"
git push --set-upstream origin develop
cd test_product
yo phovea:init-product
Plugin name: test_product
Description: A test product
Leave project homepage and author's credential as they are
Service type: Web
Service name: Testservice
Primary respository: <username or organization>/test
Primary repository branch: develop
Additional plugins: ENTER
Add custom additional plugins: N
Add another service: y
Service type: Rest-API
Service name: test_server
primary repository: phovea/phovea_server
primary repository branch: develop
Add custom additional plugin? N
Add another service? N
git add .
git commit -m "Initial commit"
git push
Create new folder named workspace and switch to it.
cd ..
mkdir workspace
cd workspace
So the test
, test_product
and workspace
should be on the same level.
yo phovea:setup-workspace <username or organization>/test_product
SSH clone: No
mkdir testserverplugin
cd testserverplugin
yo phovea:init-app-slib
cd ..
yo phovea:clone phovea_server
cd phovea_server
git checkout develop
cd ..
The directory structure should look like this now:
In the workspace folder, do:
yo phovea:workspace
cd testserverplugin
yo phovea:add-extension
# Base Type: server type: namespace, id: hello-rest, filename: hello_rest
# extras: namespace=/api/hello_rest
In the workspace folder, do:
docker-compose up
Keep this shell open all the time since the docker process is running in it. If you want, you can also run docker as a demon:
docker-compose up -d
In this case, you can close the shell after you entered the command.
Note:
cd workspace\test
npm run start:test
Open PyCharm and open the project which is located in workspace.
You can delete the test and test_product folders, since the whole application code is available in the workspace folder. Modify/extend you project as needed and commit your changes to the github repository.
Open Chrome (or any other webbrowser), enter localhost:8080. This is the root page. If you enter localhost:8080/api/hello_rest, you should get the message "Hello World" as JSON string.
Note: