snu-quiqcl / wlm-server

Server for controlling and monitoring High Finesse wavelength meter
1 stars 0 forks source link

Offer channels info #26

Closed BECATRUE closed 1 day ago

BECATRUE commented 1 day ago

This resolves #8.

I implemented the feature to offer available channels info with the url /channel/.

One can test it using the codes below.

import requests

BASE_URL = 'http://localhost:8000'

with requests.Session() as session:
    data = {'username': 'jaehun', 'password': 'dbwogns01!'}
    response = session.post(BASE_URL + '/user/signin/', data=data)
    print(response.status_code)  # 200

    csrf_token = session.cookies.get('csrftoken')
    headers = {'X-CSRFToken': csrf_token}

    response = session.get(BASE_URL + '/channel/', headers=headers)
    print(response.json())  # [{'channel': 1, 'name': 'CH 1'}, {'channel': 2, 'name': 'CH 2'}]

    response = session.post(BASE_URL + '/user/signout/', headers=headers)
    print(response.status_code)  # 200