49 lines
1.3 KiB
Markdown
49 lines
1.3 KiB
Markdown
# vue-apps-py
|
|
|
|
This is a library provided as a building block for your Vue Apps written on Python 3
|
|
|
|
You will probably need to install ***uvicorn*** to launch a server built with FastAPI
|
|
|
|
```shell
|
|
python3 -m pip install "uvicorn[standard]"
|
|
```
|
|
|
|
After importing an app such as `main.py`:
|
|
|
|
```python
|
|
from typing import List
|
|
from src.vue_apps_py.security import SecurityHelper
|
|
from src.vue_apps_py.server import VueApp, name_intents
|
|
from src.vue_apps_py.client import ClientAPI
|
|
from src.vue_apps_py.server_utils.intents import Intent, InlineQuery
|
|
from src.vue_apps_py.server_utils.models import AutoModel, SuggestionsModel
|
|
|
|
|
|
def autocomplete_handler(query_model: AutoModel) -> SuggestionsModel:
|
|
# Just log the query
|
|
print(query_model.json())
|
|
|
|
# Send back empty model
|
|
return SuggestionsModel()
|
|
|
|
|
|
# Initialize API
|
|
api = ClientAPI(client_id='vue-app-0', client_secret='abccf12389efab222')
|
|
|
|
# Prepare Security
|
|
key_holder = SecurityHelper(public_key='abbcbbbcaksjdhf/skdjhfnnsn/sjdkfjj21234=')
|
|
|
|
# Define intents
|
|
intents: List[Intent] = [InlineQuery(autocomplete_handler)]
|
|
named_intents = name_intents(intents)
|
|
|
|
# Get Vue Application Server
|
|
vue_app = VueApp(client_api=api, security_helper=key_holder, named_intents=named_intents, debug=True)
|
|
```
|
|
|
|
You can launch web server:
|
|
|
|
```shell
|
|
uvicorn test:vue_app --reload
|
|
```
|