Host a “non-django app” (a folder with index.html, some .js and .css) in a django website

0 favourites
  • 4 posts
From the Asset Store
Create your own casino app and import it to Google Play and the App Store.
  • Short brief:

    I have some “non-django html apps” (a folder with a index.html, some .js files and a .css file) and I want to execute them in a django website without touching their code. How can I do it?

    How can I make work inside django a non-django app (a folder with an index.html, some .js and .css) withou touching the code of the app?

    Details:

    I'm building a website with Django where i want to host some Construct3 games (it allows you to create HTML5 through a GUI).

    When you export a Construct3 game to HTML it creates the following structure:

    C3App |_ appmanifest.json |_ c2runtime.js |_ data.js |_ index.html |_ offline.js |_ offlineClient.js |_ register-sw.js |_ start.js |_ style.css |_ sw.js |_ icons | |_ icon1.png |_ images |_ image1.png

    That is what I have tried:

    • In my Django website I dropped the C3App in my template folder and created a view and called index.html. As a result i got a blank page with not found errors (404) for: appmanifest.json, icon1.png, style.css, c2runtime.js, start.js and register-sw.js. That is the external files called in index.html.
    • As that dindn't work, I moved C3App to my static folder and I created a template with the same content of index.html but changing the references.

    So I changed this lines:

    <link rel="manifest" href="appmanifest.json" /> <link rel="icon" type="image/png" href="icons/icon-512.png" /> <link rel="stylesheet" href="style.css"/> <script src="c2runtime.js"></script> <script src="start.js"></script> <script src="register-sw.js"></script>

    To this others:

    {% load static %} <link rel="manifest" href="{% static 'games/C3App/appmanifest.json' %}" /> <link rel="icon" type="image/png" href="{% static 'games/C3App/icons/icon-512.png' %}" /> <link rel="stylesheet" href="{% static 'games/C3App/style.css' %}"/> <script src="{% static 'games/C3App/c2runtime.js' %}"></script> <script src="{% static 'games/C3App/start.js' %}"></script> <script src="{% static 'games/C3App/register-sw.js' %}"></script>

    After the changes I got 2 not found errors for: data.js and offlineClient.js. Two files called several times in c2runtime.js.

    So c2runtime.js needs to be touched too. And this starts to become too dirty, I'm modifying more than one file, in more than one place. So every time I will want to make an update for a game I will need to modify all that files again. Sounds like stupid work and an easy way to introduce bugs.

    The perfect scenario would be drag the folder (exported game) and work. Is there a way to do that posible? Any idea?

    How can I make work inside django a non-django app (a folder with an index.html, some .js and .css) withou touching the code of the app?

  • Is there a reason you're not using iframes/xframes?

  • No but am checking the probabilities.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Is the Django library acting similar to PHP? cause if it does, then you could follow a similar path as you would do with php embeding html /css code in between the <?php echo 'your html5 code, js etc'; ?>

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)