Commit a93ac4b320dd2e42f5683c4c929e86a42a908cfe

Authored by Josh Klontz
1 parent a8291d6a

added shell code for image retrieval

Showing 1 changed file with 11 additions and 2 deletions
app/br-serve/br-serve.cpp
... ... @@ -55,6 +55,13 @@ public slots:
55 55 if (process.error() != QProcess::UnknownError)
56 56 qFatal("%s\n", qPrintable(process.errorString()));
57 57 message = process.readLine();
  58 + response->setHeader("Content-Type", "application/json");
  59 + } else if (urlQuery.hasQueryItem("imageID")) {
  60 + process.write(qPrintable(QString(urlQuery.queryItemValue("imageID") + "\n")));
  61 + process.waitForReadyRead();
  62 + if (process.error() != QProcess::UnknownError)
  63 + qFatal("%s\n", qPrintable(process.errorString()));
  64 + response->setHeader("Content-Type", "image/jpeg");
58 65 } else {
59 66 QString path = request->path();
60 67 if (path == "/")
... ... @@ -68,18 +75,20 @@ public slots:
68 75 "<body>\n"
69 76 " <h1><a href=\"http://en.wikipedia.org/wiki/Query_string\">Query String</a> Parameters</h1>"
70 77 " <ul>\n"
71   - " <li><b>url</b> - Query URL for processing.</li>\n"
  78 + " <li><b>url</b> - Query URL for image search.</li>\n"
  79 + " <li><b>imageID</b> - Query ImageID for image retrieval.</li>\n"
72 80 " </ul>\n"
73 81 " <h1>Examples</h1>\n"
74 82 " <ul>\n"
75 83 " <li>http://%1%2/?url=data.liblikely.org/misc/lenna.tiff</li>\n"
  84 + " <li>http://%1%2/?imageID=ecaee0b4cd73a76dd2a8060b2909a4a1</li>\n"
76 85 " </ul>\n"
77 86 "</body>\n"
78 87 "</html>").arg(path, port == 80 ? QString() : (QString(":") + QString::number(port))).toLatin1();
  88 + response->setHeader("Content-Type", "text/html");
79 89 }
80 90  
81 91 response->setHeader("Content-Length", QString::number(message.size()));
82   - response->setHeader("Content-Type", "application/json");
83 92 response->writeHead(200); // everything is OK
84 93 response->write(message);
85 94 response->end();
... ...