Overview

This article introduces Driver-Hub, a Feishu (Lark) Web Application I built to connect with our internal GitLab server.
The app allows searching projects, browsing branches, viewing commits, and downloading code archives directly from Feishu’s workplace UI.

The implementation is purely web-based.
Traditional bot features were removed — users open Driver-Hub in Feishu, interact with form controls, and the app communicates with GitLab APIs through FastAPI.


1. Feishu Developer Platform Setup

Before writing any code, configure a Feishu developer app to host the Driver-Hub UI.

Step 1. Create a New Application

  1. Go to your organization’s Feishu Developer Console.
  2. Click Create App → select Internal Application.
  3. Enter the name Driver-Hub, add an icon and description.
  4. Save and note your App ID and App Secret.

Step 2. Enable Web Application

  1. Left sidebar → Functional Configuration → Web Application.
  2. Enable “Workplace Web Application”.
  3. Fill homepage URLs (desktop & mobile):
    https://<your-ngrok-domain>/
    
  4. Save the configuration.

Step 3. Publish the Application

After setup, go to Version Management & ReleaseRelease → “Only visible to me”.
Then open Feishu → “Workplace” → find Driver-Hub → open the embedded page.


2. Running a Local HTTPS Endpoint with ngrok

Feishu requires a public HTTPS endpoint for embedded web pages.
Instead of deploying to the cloud, we use ngrok to expose FastAPI (localhost:3000) securely.

Step 1. Install ngrok

Using Scoop on Windows:

scoop install ngrok

Or macOS Homebrew:

brew install ngrok/ngrok/ngrok

Step 2. Connect Your Account

After signing up at https://ngrok.com:

ngrok config add-authtoken <YOUR_AUTHTOKEN>

Step 3. Start the Tunnel

ngrok http 3000

Output example:

Forwarding  https://driverhub.ngrok-free.dev -> http://localhost:3000

Use this HTTPS address in Feishu’s web app config.

⚠️ Free-tier ngrok adds a browser warning page that blocks Feishu WebView.
For stable use, upgrade ngrok or deploy Driver-Hub on an internal HTTPS server.


3. GitLab Personal Access Token

Driver-Hub communicates with GitLab via its REST API, requiring a Personal Access Token (PAT).

Step 1. Create Token

  1. Log in to your GitLab (e.g., https://gitlab.xxx.net).
  2. Go to Preferences → Access Tokens.
  3. Set:
    • Name: driver-hub
    • Scopes: api, read_repository
  4. Click Create Token, then copy it (only shown once).

Step 2. Test the Token

curl --header "PRIVATE-TOKEN: <your_token>"      https://gitlab.xxx.net/api/v4/user

Should return user info JSON.


4. FastAPI Backend

main.py serves both UI and REST endpoints.

EndpointMethodDescription
/GETServe main HTML UI
/api/config/testPOSTValidate GitLab base URL and token
/api/projectsGETSearch GitLab projects
/api/projects/{id}/branchesGETList branches
/api/projects/{id}/commitsGETList commits
/api/projects/{id}/branches/{branch}/archiveGETDownload ZIP

Example route:

@app.get("/")
def index():
    return "<h2>Driver-Hub Web UI is running</h2>"

5. Run the Application

Start FastAPI locally:

python main.py

Then start ngrok:

ngrok http 3000

Open Feishu → “Workplace” → Driver-Hub → view the web UI.


6. Summary

Driver-Hub is a lightweight internal GitLab management console embedded directly inside Feishu.
It uses Python + FastAPI for backend logic, ngrok for HTTPS tunneling, and GitLab’s REST API for project operations.

For production, host Driver-Hub on an internal server with HTTPS, e.g. https://driver-hub.xxx.net.


Project Structure

.
├── main.py
├── gitlab_client.py
├── favicon.ico
└── .env