summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-11-22 16:32:46 +0100
committerDaniel Weipert <code@drogueronin.de>2023-11-22 16:32:46 +0100
commit8bf926db1926665ad8a376971a6e35f33269b8d4 (patch)
tree05889764346fd27d144075ed8e73390ffc8dde44 /index.php
parentd017568a77d677e449e66d689450532a760d6f11 (diff)
handle video/audio/text mime types
Diffstat (limited to 'index.php')
-rw-r--r--index.php31
1 files changed, 30 insertions, 1 deletions
diff --git a/index.php b/index.php
index 23c314f..c2bb48e 100644
--- a/index.php
+++ b/index.php
@@ -64,8 +64,37 @@ if (strpos($mime, 'text/gemini') === 0) {
}
}
+else if (strpos($mime, 'text') === 0) {
+ echo $response->getBody();
+}
+
else if (strpos($mime, 'image') === 0) {
- echo "<img src=\"data:{$mime};base64," . base64_encode($response->getBody()) . "\">";
+ $src = "data:{$mime};base64," . base64_encode($response->getBody());
+ ?>
+ <img src="<?php echo $src; ?>">
+ <?php
+}
+
+else if (strpos($mime, 'video') === 0) {
+ $src = "data:{$mime};base64," . base64_encode($response->getBody());
+ ?>
+ <video controls>
+ <source src="<?php echo $src; ?>" type="<?php echo $mime; ?>">
+ </video>
+ <?php
+}
+
+else if (strpos($mime, 'audio') === 0) {
+ $src = "data:{$mime};base64," . base64_encode($response->getBody());
+ ?>
+ <audio controls>
+ <source src="<?php echo $src; ?>" type="<?php echo $mime; ?>">
+ </audio>
+ <?php
+}
+
+else {
+ echo "Unhandled MIME type: $mime";
}
echo "<hr>";