Download app.js from sharon55/appwizard: direct link, hf CLI and curl.
- Browser
- Download file 2.47 kB
-
https://huggingface.co/spaces/sharon55/appwizard/resolve/main/app.js
- Command line
-
hf download hf://spaces/sharon55/appwizard/app.js
-
curl -L -o app.js https://huggingface.co/spaces/sharon55/appwizard/resolve/main/app.js
2.47 kB
| ```javascript | |
| // Flask backend for AppWizard | |
| const express = require('express'); | |
| const app = express(); | |
| const port = 3000; | |
| // Sample app registry | |
| const appRegistry = { | |
| "whatsapp": { | |
| "name": "WhatsApp", | |
| "androidPackage": "com.whatsapp", | |
| "iosSchemes": ["whatsapp://","https://wa.me/"], | |
| "categories": ["social","messaging"] | |
| }, | |
| "uber": { | |
| "name": "Uber", | |
| "androidPackage": "com.ubercab", | |
| "iosSchemes": ["uber://"], | |
| "categories": ["cabs","transport"] | |
| }, | |
| "ola": { | |
| "name": "Ola", | |
| "androidPackage": "com.olacabs.customer", | |
| "iosSchemes": ["ola://"], | |
| "categories": ["cabs","transport"] | |
| } | |
| }; | |
| // Intent parser | |
| function parseIntent(input) { | |
| input = input.toLowerCase().trim(); | |
| // Check for direct app opening | |
| if (input.startsWith("open ")) { | |
| const appName = input.substring(5); | |
| for (const [id, app] of Object.entries(appRegistry)) { | |
| if (app.name.toLowerCase().includes(appName)) { | |
| return { | |
| type: "open_app", | |
| appId: id, | |
| candidates: [id], | |
| confidence: 0.9, | |
| needsDisambiguation: false | |
| }; | |
| } | |
| } | |
| } | |
| // Check for categories | |
| const categories = { | |
| "cab": ["uber", "ola"], | |
| "taxi": ["uber", "ola"], | |
| "ride": ["uber", "ola"], | |
| "food": ["swiggy", "zomato"], | |
| "music": ["spotify", "youtube music"] | |
| }; | |
| for (const [keyword, apps] of Object.entries(categories)) { | |
| if (input.includes(keyword)) { | |
| const installedApps = apps.filter(app => appRegistry[app]); | |
| return { | |
| type: "open_category", | |
| category: keyword, | |
| candidates: installedApps, | |
| confidence: 0.7, | |
| needsDisambiguation: installedApps.length > 1 | |
| }; | |
| } | |
| } | |
| return { | |
| type: "unknown", | |
| candidates: [], | |
| confidence: 0, | |
| needsDisambiguation: false | |
| }; | |
| } | |
| // Routes | |
| app.get('/api/parse', (req, res) => { | |
| const query = req.query.q; | |
| if (!query) { | |
| return res.status(400).json({ error: "Missing query parameter" }); | |
| } | |
| const result = parseIntent(query); | |
| res.json(result); | |
| }); | |
| app.listen(port, () => { | |
| console.log(`AppWizard backend running on port ${port}`); | |
| }); | |
| ``` |