Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial implementation of /parts endpoint #1

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: CI
on: [push, pull_request]
jobs:
tests:
name: Check
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Install dependencies
run: pip install -r requirements-dev.txt
- name: Run flake8
run: flake8
- name: Run isort
run: isort --check --diff .
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
*.autosave
*.swp
.DS_Store
config/
Thumbs.db
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
ARG ALPINE_TAG
FROM alpine:$ALPINE_TAG

# Install packages.
RUN apk add --no-cache \
python3 \
py3-flask \
py3-flask-pyc \
py3-gunicorn \
py3-gunicorn-pyc \
py3-requests \
py3-requests-pyc

# Copy files.
COPY app.py app/
COPY static/ app/static/
WORKDIR app

# Set entrypoint.
ENTRYPOINT [ \
"gunicorn", \
"--access-logfile=-", \
"--bind=0.0.0.0:8000", \
"--forwarded-allow-ips=*", \
"--workers=4", \
"app:app" \
]
619 changes: 619 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,45 @@
# librepcb-api-server

Official server-side implementation of the
[LibrePCB API](https://developers.librepcb.org/d1/dcb/doc_server_api.html)
as accessed by the LibrePCB application. Note that some older API paths are
implemented in a different way and might be migrated to this repository
later.

## Requirements

Only Docker Compose is needed to run this server on a Linux machine.

## Configuration

To make all features working, a configuration file `config/api.json` is
required with the following content:

```json
{
/* Config for endpoint '/parts' */
"parts_operational": false,
"parts_query_url": "",
"parts_query_token": ""
}
```

## Usage

For local development, the server can be run with this command:

```bash
docker-compose up --build
```

Afterwards, the API runs on http://localhost:8000/:

```bash
curl -X POST -H "Content-Type: application/json" -d @demo-request.json \
'http://localhost:8000/api/v1/parts/query' | jq '.'
```

## License

The content in this repository is published under the
[GNU GPLv3](http://www.gnu.org/licenses/gpl-3.0.html) license.
Loading
Loading