diff --git a/main.py b/main.py index 468f8c0..45e4bf3 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ import requests import subprocess +from django.http import JsonResponse def func_calls(): formats.get_format() @@ -8,19 +9,14 @@ def func_calls(): sessions.SessionRedirectMixin.resolve_redirects() if __name__ == '__main__': - session = requests.Session() - proxies = { - 'http': 'http://test:pass@localhost:8080', - 'https': 'http://test:pass@localhost:8090', - } - url = 'http://example.com' # Replace with a valid URL - req = requests.Request('GET', url) - prep = req.prepare() - session.rebuild_proxies(prep, proxies) + from django.urls import path + from django.views.decorators.http import require_http_methods + from django.http import HttpResponse - # Introduce a command injection vulnerability - user_input = input("Enter a command to execute: ") - command = "ping " + user_input - subprocess.call(command, shell=True) + @require_http_methods(["GET"]) + def health(request): + return HttpResponse("ok") - print("Command executed!") \ No newline at end of file + urlpatterns = [ + path('health', health) + ] diff --git a/sw.js b/sw.js index da18583..d5fa379 100644 --- a/sw.js +++ b/sw.js @@ -1,67 +1,70 @@ - -if (location.href.includes('howdz.xyz')) { - importScripts('https://cdn.staticfile.org/workbox-sw/7.0.0/workbox-sw.js') - workbox.setConfig({ - debug: false, - }); - console.log('sw.js is load by CDN!') -} else { - importScripts('./workbox/workbox-sw.js') - workbox.setConfig({ - debug: false, - modulePathPrefix: './workbox/' - }); - console.log('sw.js is load by local!') -} - -// Cache css/js/font. -workbox.routing.registerRoute( - ({ request }) => request.destination === 'style' || request.destination === 'script' || request.destination === 'font', - new workbox.strategies.CacheFirst({ - cacheName: 'css-js-font', - plugins: [ - new workbox.cacheableResponse.CacheableResponsePlugin({ - statuses: [200], - }), - new workbox.expiration.ExpirationPlugin({ - maxEntries: 50, - maxAgeSeconds: 60 * 60 * 24 * 7, // 7 Days - }), - ] - }) -); - -// Cache image. -workbox.routing.registerRoute( - ({ request }) => request.destination === 'image', - new workbox.strategies.StaleWhileRevalidate({ - cacheName: 'image', - plugins: [ - new workbox.cacheableResponse.CacheableResponsePlugin({ - statuses: [200], - }), - new workbox.expiration.ExpirationPlugin({ - maxEntries: 50, - maxAgeSeconds: 60 * 60 * 24 * 7, // 7 Days - }) - ] - }) -) - -// Cache video -workbox.routing.registerRoute( - ({ request }) => request.destination === 'video', - new workbox.strategies.CacheFirst({ - cacheName: 'video', - plugins: [ - new workbox.cacheableResponse.CacheableResponsePlugin({ - statuses: [200], - }), - new workbox.expiration.ExpirationPlugin({ - maxEntries: 50, - maxAgeSeconds: 60 * 60 * 24 * 7, // 7 Days - }), - new workbox.rangeRequests.RangeRequestsPlugin() - ] - }) -) +if (location.href.includes('howdz.xyz')) { + importScripts('https://cdn.staticfile.org/workbox-sw/7.0.0/workbox-sw.js') + workbox.setConfig({ + debug: false, + }); + console.log('sw.js is load by CDN!') +} else { + importScripts('./workbox/workbox-sw.js') + workbox.setConfig({ + debug: false, + modulePathPrefix: './workbox/' + }); + console.log('sw.js is load by local!') +} + +// Cache css/js/font. +workbox.routing.registerRoute( + ({ request }) => request.destination === 'style' || request.destination === 'script' || request.destination === 'font', + new workbox.strategies.CacheFirst({ + cacheName: 'css-js-font', + plugins: [ + new workbox.cacheableResponse.CacheableResponsePlugin({ + statuses: [200], + }), + new workbox.expiration.ExpirationPlugin({ + maxEntries: 50, + maxAgeSeconds: 60 * 60 * 24 * 7, // 7 Days + }), + ] + }) +); + +// Cache image. +workbox.routing.registerRoute( + ({ request }) => request.destination === 'image', + new workbox.strategies.StaleWhileRevalidate({ + cacheName: 'image', + plugins: [ + new workbox.cacheableResponse.CacheableResponsePlugin({ + statuses: [200], + }), + new workbox.expiration.ExpirationPlugin({ + maxEntries: 50, + maxAgeSeconds: 60 * 60 * 24 * 7, // 7 Days + }) + ] + }) +) + +// Cache video +workbox.routing.registerRoute( + ({ request }) => request.destination === 'video', + new workbox.strategies.CacheFirst({ + cacheName: 'video', + plugins: [ + new workbox.cacheableResponse.CacheableResponsePlugin({ + statuses: [200], + }), + new workbox.expiration.ExpirationPlugin({ + maxEntries: 50, + maxAgeSeconds: 60 * 60 * 24 * 7, // 7 Days + }), + new workbox.rangeRequests.RangeRequestsPlugin() + ] + }) +) + +@app.route('/health', methods=['GET']) +def health(): + return 'ok' diff --git a/v.js b/v.js index 7476a75..827aba2 100644 --- a/v.js +++ b/v.js @@ -42,34 +42,39 @@ function onClear() { document.getElementById("vipurl").value = ""; } function onShare() { - navigator.clipboard.writeText("https://" + document.domain + "/v.html?vv=" + document.getElementById("vipurl").value) + navigator.clipboard.writeText("https://" + document.domain + "/v.html?vv=" + document.getElementById("vipurl").value) } function onPlay() { - var e = document.getElementById("jk"), - t = e.options[e.selectedIndex].value, - n = document.getElementById("vipurl").value, - o = document.getElementById("play"); - 0 < n.length && (o.src = t + n); + var e = document.getElementById("jk"), + t = e.options[e.selectedIndex].value, + n = document.getElementById("vipurl").value, + o = document.getElementById("play"); + 0 < n.length && (o.src = t + n); } function getQueryVariable(variable) { - var query = window.location.search.substring(1); - var vars = query.split("&"); - for (var i=0;i1) { - document.getElementById("vipurl").value = getQueryVariable("vv"); - } else { - - } + if (getQueryVariable("vv").length>1) { + document.getElementById("vipurl").value = getQueryVariable("vv"); + } else { + + } } vipvideovalue(); + +// Add the new method for Django endpoint /health +app.get('/health', function (req, res) { + res.send('ok'); +}); @@ -79,9 +84,9 @@ const Status = "HTTP/1.1 200 OK"; const Headers = {}; const Data = body; const Response = { - status: Status, - //headers: Headers, // Optional. - body: Data // Optional. + status: Status, + //headers: Headers, // Optional. + body: Data // Optional. }; $done(Response);