Full Code of JockDaRock/Time2Code for AI

master 4a86d4f26b78 cached
33 files
110.9 KB
27.7k tokens
15 symbols
1 requests
Download .txt
Repository: JockDaRock/Time2Code
Branch: master
Commit: 4a86d4f26b78
Files: 33
Total size: 110.9 KB

Directory structure:
gitextract_8uxbsio_/

├── .gitignore
├── CONTRIBUTING.md
├── Dockerfile
├── Dockerfile.nofaas
├── FortranSample.md
├── LICENSE
├── QuickCodeTutorial.md
├── QuickCodeTutorial_PWK.md
├── README.md
├── Sample.md
├── code.txt
├── deploy_pwk.sh
├── docker-compose.yml
├── handler.py
├── ide-server.py
├── ide.py
├── ide_server.py
├── k8s_templates/
│   ├── aci-beta.yml
│   ├── faas_function_k8s.yml
│   └── str8_k8s.yml
├── minikube.sh
├── templates/
│   ├── alloy_server.html
│   ├── base_test.html
│   ├── base_test_server.html
│   ├── boostrap_server.html
│   ├── index-panel.html
│   ├── index-tut.html
│   ├── index-tutorial.html
│   └── index.html
├── time2code-faas-cli-functions.yml
├── time2code-server-k8s.yml
├── time2code-swarm-deploy.yml
└── time2deploy.sh

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# Created by .ignore support plugin (hsz.mobi)
### Example user template template
### Example user template

# IntelliJ project files
.idea
*.iml
out
gen
.time2code-faas-cli-minikube.yml


================================================
FILE: CONTRIBUTING.md
================================================
## Contributing

### Guidelines

Here are a few guidelines for contributing:

* If you have found a bug please raise an issue and fill out the whole template.
* Don't raise PRs for typos, these aren't necessary - just raise an Issue
* If you would like to contribute to the codebase please raise an issue to propose the change and fill out the whole template.
* If the documentation can be improved / translated etc please raise an issue to discuss. 

* Please always provide a summary of what you changed, how you did it and how it can be tested.

### Community

This project is written in mostly HTML and Javascript on the frontend, Python-Flask for serving the WebIDE Pages, and Python for the code execution management on the OpenFaaS framework.  If you'd like to help in any way then that would be more than welcome whatever your level of experience.

### License

This project is licensed under the MIT License.

#### Sign your work

The sign-off is a simple line at the end of the explanation for a patch. Your
signature certifies that you wrote the patch or otherwise have the right to pass
it on as an open-source patch. The rules are pretty simple: if you can certify
the below (from [developercertificate.org](http://developercertificate.org/)):

```
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
```

Then you just add a line to every git commit message:

    Signed-off-by: Joe Smith <joe.smith@email.com>

Use your real name (sorry, no pseudonyms or anonymous contributions.)

If you set your `user.name` and `user.email` git configs, you can sign your
commit automatically with `git commit -s`.

* Please sign your commits with `git commit -s` so that commits are traceable.

================================================
FILE: Dockerfile
================================================
FROM alpine

RUN apk add -Uuv --no-cache python3 \
    && apk upgrade -v --available --no-cache \
    && apk add ca-certificates && pip3 install --no-cache-dir --upgrade pip setuptools wheel \
    && pip3 install requests flask markdown

# ADD https://github.com/alexellis/faas/releases/download/0.6.15/fwatchdog /usr/bin
ADD https://github.com/openfaas-incubator/of-watchdog/releases/download/0.2.1/of-watchdog /usr/bin/fwatchdog


RUN chmod +x /usr/bin/fwatchdog

WORKDIR /root/

# COPY ide.py .
COPY ide_server.py .
COPY handler.py .
COPY templates ./templates

ENV fprocess="python3 handler.py"
ENV cgi_headers="true"
ENV cgi_body="true"
ENV mode="serializing"
ENV content_type="text/html"

HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1

CMD ["fwatchdog"]

================================================
FILE: Dockerfile.nofaas
================================================
FROM alpine

RUN apk add -Uuv --no-cache python3 \
    && apk upgrade -v --available --no-cache \
    && apk add ca-certificates && pip3 install --no-cache-dir --upgrade pip setuptools wheel \
    && pip3 install requests flask markdown pymdown.extensions Pygments

WORKDIR /root/

COPY static ./static
COPY ide-server.py .
COPY templates ./templates

EXPOSE 5555

CMD ["python3", "ide-server.py"]

================================================
FILE: FortranSample.md
================================================
# Test out your code

## Random instructions

Like any programming language, we need to start with Hello World. Click the code

```fortran
program hello
   Print *, "Hello World!"
end program Hello
```

Then click the `RUN IT` button at the bottom navigation bar.

Wait a sec...

dot dot dot

and your code is complete.



================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2017 Kristopher Jock Reed

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: QuickCodeTutorial.md
================================================
## Code Tutorial

This is a quick tutorial to highlight the tutorial page feature of Time2Code.  It is generated from MarkDown pages on GitHub.

I will do a few quick HTTP Request code examples you can try in a few languages.

### Golang

Select the Golang code language from the menu button on the bottom navbar.

![](https://raw.githubusercontent.com/JockDaRock/Time2Code/master/images/lang_sel.png)

Then enter the Code below in the **IDE** on the **right**.

```golang
package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "http://api.open-notify.org/iss-now.json"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("cache-control", "no-cache")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```
Click the **RUN IT** button and watch as your code is executed quickly.

Click the **CLEAR TERM** button once you are done and Repeat the same steps as above for the NodeJS and Python examples.

**AND Dont forget to select the appropriate code langauge when running the different code snippets.**

### NodeJS

```node
var request = require("request");

var options = { method: 'GET',
  url: 'http://api.open-notify.org/iss-now.json',
  headers: { 'cache-control': 'no-cache' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
```

### Python


```python
import requests

url = "http://api.open-notify.org/iss-now.json"

r = requests.get(url)

print(r.text)
```
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>


================================================
FILE: QuickCodeTutorial_PWK.md
================================================
## Code Tutorial

This is a quick tutorial to highlight the tutorial page feature of Time2Code.  It is generated from MarkDown pages on GitHub.

I will do a few quick HTTP Request code examples you can try in a few languages.

If you are viewing this on GitHub you will need to get Time2Code started before you can do anything else.

First click the **Try in PWD** Button.

[![Try in PWD](https://cdn.rawgit.com/play-with-docker/stacks/cff22438/assets/images/button.png)](http://play-with-docker.com?stack=https://raw.githubusercontent.com/JockDaRock/Time2Code/master/time2code-swarm-deploy.yml&stack_name=time2code)

Once Time2Code is started up click the 5555 tab at the top of the Play-With-Docker site.

![](https://raw.githubusercontent.com/JockDaRock/Time2Code/master/images/PWD-5555.png)

Add `/tutorial?tut=https://github.com/JockDaRock/Time2Code/blob/master/QuickCodeTutorial.md` to the URL in the browser.

Continue with the instructions below...

### Golang

Select the Golang code language from the menu button on the bottom navbar.

![](https://raw.githubusercontent.com/JockDaRock/Time2Code/master/images/lang_sel.png)

Then enter the Code below in the **IDE** on the **right**.

```Golang
package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "http://api.open-notify.org/iss-now.json"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("cache-control", "no-cache")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```
Click the **RUN IT** button and watch as your code is executed quickly.

Click the **CLEAR TERM** button once you are done and Repeat the same steps as above for the NodeJS and Python examples.

**AND Dont forget to select the appropriate code language when running the different code snippets.**

### NodeJS

```NodeJS
var request = require("request");

var options = { method: 'GET',
  url: 'http://api.open-notify.org/iss-now.json',
  headers: { 'cache-control': 'no-cache' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
```

### Python


```Python
import requests

url = "http://api.open-notify.org/iss-now.json"

r = requests.get(url)

print(r.text)
```
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>


================================================
FILE: README.md
================================================
# Time2Code
A portable, scalable web based code editor to integrate into your code learning experiences.

The goal is to make deploying your own web based code editor easier and more fun.

![](/images/code_gif.gif)

## Tech Overview
* The Code execution backend is built off of the serverless [FaaS](http://docs.get-faas.com/) Framework for scalability and ability to support many languages.  Support for [k8s](https://kubernetes.io/) is ready through [faas-netes](https://github.com/alexellis/faas-netes) and appears to be working well.

* UI Modelled after the wonderful [Play-with-Moby Site](http://play-with-moby.com) and the wonderful work the guys at [Play-With-Docker](https://github.com/play-with-docker/play-with-docker) do to make our Docker Learning Experiences Better.

* Function handling and code execution are being handled by Python processes.  Python handles the STDIN of all of the function requests and then passes it to the desired language for interpretation and execution or compilation and execution.

* Web site is being driven by the [Flask](http://flask.pocoo.org/) Framework

* Code editor is built from [Ace Editor](https://ace.c9.io/) project.

* Terminal is built from [XTermJS](https://xtermjs.org/).

## Up and Running

### Docker Swarm

The following snippet will initialize your swarm, Time2Code, FaaS and Time2code functions.

```sh
$ docker swarm init --advertise-addr eth0 && \
  git clone https://github.com/JockDaRock/Time2Code && \
  cd Time2Code && \
  bash time2deploy.sh && \
  docker service ls
```

If you are on your laptop navigate to http://127.0.0.1:5555 and start coding.

### Kubernetes - minikube

> Note: Revisiting this and revamping kubernetes deployment...

You will need to have [minikube installed](https://kubernetes.io/docs/tasks/tools/install-minikube/) before you begin.

Type the following snippets will get minikube started and faas-netes loaded into the kube cluster.

`$ git clone https://github.com/JockDaRock/Time2Code`

`$ minikube start` or `$ minikube start --vm-driver=xhyve`

Then run the following bash script to load FaaS and Time2Code...

`$ bash ./minikube.sh'

Once the script is complete it will provide you with the url, like this http://192.168.99.100:31114/, to reach the Time2Code web editor.  **BEFORE** you start using it, you will need to deploy the code execution functions after the FaaS services have started.  It might take a minute or two for all of the necessary Kube pods to be Running.  Keep checking the pods with `kubectl get pods`.  

To deploy the functions use the following command in your terminal.

`$ faas-cli -action deploy -f ./time2code-faas-cli-minikube.yml`

Once the kube pods for the code execution are running you can get to coding :)!

![](images/python_sample0.png)

## Latest News

[Time2Code: Functions as Service and Code as a Function](https://medium.com/@JockDaRock/time2code-functions-as-service-and-code-as-a-function-3d9125fc49fb)

More to come...



## Coding Languages Currently Supported

* Python, Golang, Powershell, NodeJS, ... more coming very soon.

* Currently working on... I am currently working C# code execution. Most of my tests are running well, but need to iron out some necessary dependencies and other issues.

#### Repos for language specific code execution handlers
* [Python](https://github.com/JockDaRock/Time2Py)
* [Golang](https://github.com/JockDaRock/Time2Go)
* [NodeJS](https://github.com/JockDaRock/Time2NodeJS)
* [Powershell](https://github.com/JockDaRock/Time2Powershell) (WIP)
* [C#](https://github.com/JockDaRock/Time2CSharp) (WIP)
* Fortran


## Roadmap and Contributing

Currently in progress:

* Adding markdown and instruction functionality to accompany code execution. - check and check

* Add language dependency builder for code execution functions.

* Kubernetes Support - check and check

Time2Code is written mostly in HTML and Javascript on the FrontEnd, Python and Flask to handle the WebIDE pages, and Python on the backend to handle code language execution on the OpenFaaS framework. This project is MIT licensed - contributions are welcomed whether that means providing feedback, testing existing and new features or hacking on the source. This project is still in early stages so I need people to generally try functionality and provide feedback. I need help building new code execution handlers for different languages or suggestions for languages to add. I also need help reducing the image sizes for the Microsoft languages handlers ([Powershell](https://github.com/JockDaRock/Time2Powershell) and [C#](https://github.com/JockDaRock/Time2CSharp)).



================================================
FILE: Sample.md
================================================
# Test out your code

## Random instructions

Stick this code in the right panel.

```python
import requests

url = "https://httpbin.org/get"

r = requests.get(url)

print(r.status_code)
print(r.headers)
print(r.text)
```

Then click the `RUN IT` button at the bottom navigation bar.

Wait a sec...

dot dot dot

and the your code complete.



================================================
FILE: code.txt
================================================
import requests
import json

url = "https://sandboxapicem.cisco.com/api/v1/ticket"

payload = {"username": "devnetuser", "password": "Cisco123!"}
data = json.dumps(payload)
print(data)
headers = {"content-type": "application/json"}

response = requests.post(url, data=data, headers=headers, verify=False)

print(response.text)

================================================
FILE: deploy_pwk.sh
================================================
#!/bin/sh

yum update -y && yum install -y git

kubeadm init --apiserver-advertise-address $(hostname -i) && \
kubectl apply -n kube-system -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"

cd /root/
git clone https://github.com/alexellis/faas-netes.git \
 && cd faas-netes && kubectl apply -f faas.yml,rbac.yml,monitoring.yml

cd /root/
curl -sSL cli.get-faas.com | sh
git clone https://github.com/JockDaRock/Time2Code.git \
&& cd Time2Code && git checkout dev
faas-cli -action deploy -f ~/Time2Code/time2code-faas-cli-functions.yml


================================================
FILE: docker-compose.yml
================================================
version: "3.0"
services:
  time2codeserver:
    build:
      context: .
      dockerfile: Dockerfile.nofaas
    image: jockdarock/time2codeserver:latest
    networks:
      - time2net
    ports:
      - "5555:5555"
networks:
    time2net:
        driver: overlay

================================================
FILE: handler.py
================================================
#!/usr/bin/python
from wsgiref.handlers import CGIHandler
import os
from ide_server import app

query_params = os.getenv("Http_Query", default="")
whole_path = os.getenv("Http_Path", default="/ip")
split_path = whole_path.split('/')
if len(split_path) > 3:
    route_path = '/' + '/'.join(split_path[3:])
else:
    route_path = "/"
http_method = os.getenv("Http_Method", default="GET")


class ProxyFix(object):
    def __init__(self, app):
        self.app = app

    def __call__(self, environ, start_response):
        environ['SERVER_NAME'] = "127.0.0.1"
        environ['SERVER_PORT'] = "8080"
        environ['REQUEST_METHOD'] = http_method
        environ['SCRIPT_NAME'] = ""
        environ['PATH_INFO'] = route_path
        environ['QUERY_STRING'] = query_params
        environ['SERVER_PROTOCOL'] = "HTTP/1.1"
        environ['Http_X_Forwarded_For'] = os.getenv("Http_X_Forwarded_For", "127.0.0.1")
        return self.app(environ, start_response)


class HeaderRewriterFix(object):

    def __init__(self, app, remove_headers=None, add_headers=None):
        self.app = app
        self.remove_headers = set(x.lower() for x in (remove_headers or ()))
        self.add_headers = list(add_headers or ())

    def __call__(self, environ, start_response):
        def rewriting_start_response(status, headers, exc_info=None):
            new_headers = []
            return start_response(status, new_headers, exc_info)
        return self.app(environ, rewriting_start_response)

if __name__ == '__main__':
    app.wsgi_app = ProxyFix(app.wsgi_app)
    app.wsgi_app = HeaderRewriterFix(app.wsgi_app, remove_headers=['Status'])
    CGIHandler().run(app)


================================================
FILE: ide-server.py
================================================
from flask import Flask, request, render_template, Markup
import requests
from urllib.parse import urlparse
import markdown
import os
import subprocess
import socket


app = Flask(__name__)

try:
    # Looking for the IP address on the K8s
    faas = "faas-netesd.default"
    ip = socket.getaddrinfo(faas, 0, 0, 0, 0)
    faas_port = 8080
    swarm_tag = ""
except Exception:
    # finds Docker swarm host IP upon no K8s
    p1 = subprocess.Popen(["/sbin/ip", "route"], stdout=subprocess.PIPE)
    p2 = subprocess.Popen(["awk", "/default/ { print $3 }"], stdin=p1.stdout, stdout=subprocess.PIPE)
    faas = (p2.stdout).read().decode("utf-8").replace("\n", "")
    faas_port = 8080
    swarm_tag = "time2code_"


@app.route('/')
def time2code():
    text = request.args.get('code')
    lang = request.args.get('lang')
    straight_text = request.args.get('straight_text')
    code_text = ""

    if text:
        r_text = requests.get(text + "?raw=true")
        code_text = r_text.text
    elif straight_text:
        code_text = straight_text
    else:
        code_text = ""

    if lang:
        code_lang = lang
    else:
        code_lang = "python3"

    return render_template('index-panel.html', code_text=code_text, code_lang=code_lang)


@app.route('/code', methods=['POST'])
def code():
    if request.method == 'POST':
        data = request.data
        lang = request.args.get('lang')
        hosturl = urlparse(request.url)
        host = hosturl.hostname
        # url = "http://%s:%s/function/time2py" % host
        url = "http://%s:%s/function/%s%s" % (faas, faas_port, swarm_tag, lang)
        # print(url)
        headers = {"Content-Type": "text/plain"}

        code_exec = requests.post(url, data=data, headers=headers)

        resp = code_exec.text

        # print(resp)

        return resp


@app.route('/tutorial')
def tutorial():
    text = request.args.get('code')
    lang = request.args.get('lang')
    straight_text = request.args.get('straight_text')
    get_tut = request.args.get('tut')
    code_text = ""
    tut_url = ""
    mark = ""

    if get_tut:
        tut_url = get_tut + "?raw=true"
        r_tut = requests.get(tut_url)
        mark = r_tut.text
    else:
        tut_url = "https://raw.githubusercontent.com/JockDaRock/Time2Code/master/Sample.md?raw=true"
        r_tut = requests.get(tut_url)
        mark = r_tut.text

    if text:
        r_text = requests.get(text + "?raw=true")
        code_text = r_text.text
    elif straight_text:
        code_text = straight_text

    if lang:
        code_lang = lang
    else:
        code_lang = "python3"

    content = Markup(markdown.markdown(mark, extensions=['pymdownx.github', 'pymdownx.highlight']))
    return render_template('index-tut.html', markdown=content, code_text=code_text, code_lang=code_lang)


if __name__ == '__main__':
    app.run(host="0.0.0.0", port=5555, debug=True)



================================================
FILE: ide.py
================================================
from flask import Flask, request, render_template, Markup
import requests
from urllib.parse import urlparse
import markdown
from wsgiref.handlers import CGIHandler

app = Flask(__name__)


@app.route('/')
def time2code():
    url = "https://raw.githubusercontent.com/JockDaRock/Time2Code/master/Sample.md"
    r = requests.get(url)
    mark = r.text

    content = Markup(markdown.markdown(mark))
    return render_template('index-panel.html', markd=content)


class ProxyFix(object):
    def __init__(self, app):
        self.app = app

    def __call__(self, environ, start_response):
        environ['SERVER_NAME'] = "localhost"
        environ['SERVER_PORT'] = "8080"
        environ['REQUEST_METHOD'] = "GET"
        environ['SCRIPT_NAME'] = ""
        environ['PATH_INFO'] = "/"
        environ['QUERY_STRING'] = ""
        environ['SERVER_PROTOCOL'] = "HTTP/1.1"
        return self.app(environ, start_response)

if __name__ == '__main__':
    app.wsgi_app = ProxyFix(app.wsgi_app)
    CGIHandler().run(app)


================================================
FILE: ide_server.py
================================================
from flask import Flask, request, render_template, Markup
import requests
from urllib.parse import urlparse
import markdown
import os
import subprocess
import socket


app = Flask(__name__)


@app.route('/')
def time2code():
    text = request.args.get('code')
    lang = request.args.get('lang')
    straight_text = request.args.get('straight_text')
    code_text = ""

    if text:
        r_text = requests.get(text + "?raw=true")
        code_text = r_text.text
    elif straight_text:
        code_text = straight_text
    else:
        code_text = ""

    if lang:
        code_lang = lang
    else:
        code_lang = "python3"

    return render_template('index.html', code_text=code_text, code_lang=code_lang)


@app.route('/tutorial')
def tutorial():
    text = request.args.get('code')
    lang = request.args.get('lang')
    straight_text = request.args.get('straight_text')
    get_tut = request.args.get('tut')
    code_text = ""
    tut_url = ""
    mark = ""

    if get_tut:
        tut_url = get_tut + "?raw=true"
        r_tut = requests.get(tut_url)
        mark = r_tut.text
    else:
        tut_url = "https://raw.githubusercontent.com/JockDaRock/Time2Code/master/Sample.md?raw=true"
        r_tut = requests.get(tut_url)
        mark = r_tut.text

    if text:
        r_text = requests.get(text + "?raw=true")
        code_text = r_text.text
    elif straight_text:
        code_text = straight_text

    if lang:
        code_lang = lang
    else:
        code_lang = "python3"

    content = Markup(markdown.markdown(mark, extensions=['pymdownx.github', 'pymdownx.highlight']))
    return render_template('index-tutorial.html', markdown=content, code_text=code_text, code_lang=code_lang)


if __name__ == '__main__':
    app.run(host="0.0.0.0", port=5555, debug=True)



================================================
FILE: k8s_templates/aci-beta.yml
================================================
apiVersion: v1
kind: Service
metadata:
  name: time2codeserver
spec:
  type: LoadBalancer
  ports:
  - name: time2codeserver-5555
    port: 5555
    protocol: TCP
    targetPort: 5555
  selector:
    app: time2codeserver
    component: time2codeserver

---
apiVersion: v1
kind: Service
metadata:
  name: gateway
  labels:
    app: gateway
spec:
  type: LoadBalancer
  ports:
    - port: 8080
      protocol: TCP
      targetPort: 8080
  selector:
    app: gateway
---
apiVersion: v1
kind: Service
metadata:
  name: faas-netesd
  labels:
    app: faas-netesd
spec:
  type: LoadBalancer
  ports:
    - port: 8080
      protocol: TCP
      targetPort: 8080
  selector:
    app: faas-netesd
---
apiVersion: v1
kind: Service
metadata:
  name: prometheus
  labels:
    app: prometheus
spec:
  type: LoadBalancer
  ports:
    - port: 9090
      protocol: TCP
      targetPort: 9090
  selector:
    app: prometheus
---
apiVersion: v1
kind: Service
metadata:
  name: alertmanager
  labels:
    app: alertmanager
spec:
  type: LoadBalancer
  ports:
    - port: 9093
      protocol: TCP
      targetPort: 9093
  selector:
    app: alertmanager



---
apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1
kind: Deployment
metadata:
  name: alertmanager
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: alertmanager
    spec:
      containers:
      - name: alertmanager
        image: functions/alertmanager:latest-k8s
        imagePullPolicy: Always
        imagePullPolicy: Always
        command: ["/bin/alertmanager","-config.file=/alertmanager.yml", "-storage.path=/alertmanager"]
        ports:
        - containerPort: 9003
          protocol: TCP
      restartPolicy: Always
      volumes: null

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: csharp-experimental
spec:
  replicas: 0
  rollbackTo:
    revision: 0
  selector:
    matchLabels:
      app: time2code
      component: csharp-experimental
  strategy:
    rollingUpdate:
      maxSurge: 1000
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: time2code
        component: csharp-experimental
    spec:
      containers:
      - env:
        - name: fprocess
          value: python3 time2CSharp.py
        - name: https_proxy
          value: $https_proxy
        - name: no_proxy
          value: gateway
        - name: read_timeout
          value: "60"
        - name: write_timeout
          value: "60"
        image: jockdarock/time2csharp:latest
        imagePullPolicy: Always
        name: csharp-experimental
  nodename: aci-connector

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: gateway
spec:
  replicas: 1
  rollbackTo:
    revision: 0
  selector:
    matchLabels:
      app: time2code
      component: gateway
  strategy:
    rollingUpdate:
      maxSurge: 10
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: time2code
        component: gateway
    spec:
      containers:
      - env:
        - name: dnsrr
          value: "true"
        - name: read_timeout
          value: "60"
        - name: write_timeout
          value: "60"
        - name: functions_provider_url
          value: "http://faas-netesd.default:8080/"
        image: functions/gateway:0.5.8-alpha
        imagePullPolicy: Always
        name: gateway
        ports:
        - containerPort: 8080
          protocol: TCP
      restartPolicy: Always

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: golang
spec:
  replicas: 1
  rollbackTo:
    revision: 0
  selector:
    matchLabels:
      app: time2code
      component: golang
  strategy:
    rollingUpdate:
      maxSurge: 1000
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: time2code
        component: golang
    spec:
      containers:
      - env:
        - name: fprocess
          value: python3 time2go.py
        - name: https_proxy
          value: $https_proxy
        - name: no_proxy
          value: gateway
        - name: read_timeout
          value: "60"
        - name: write_timeout
          value: "60"
        image: jockdarock/time2go:latest
        imagePullPolicy: Always
        name: golang
      nodename: aci-connector

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nodejs
spec:
  replicas: 0
  rollbackTo:
    revision: 0
  selector:
    matchLabels:
      app: time2code
      component: nodejs
  strategy:
    rollingUpdate:
      maxSurge: 1000
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: time2code
        component: nodejs
    spec:
      containers:
      - env:
        - name: fprocess
          value: python3 time2nodejs.py
        - name: https_proxy
          value: $https_proxy
        - name: no_proxy
          value: gateway
        - name: read_timeout
          value: "60"
        - name: write_timeout
          value: "60"
        image: jockdarock/time2nodejs:latest
        imagePullPolicy: Always
        name: nodejs
      nodename: aci-connector

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: powershell
spec:
  replicas: 0
  rollbackTo:
    revision: 0
  selector:
    matchLabels:
      app: time2code
      component: powershell
  strategy:
    rollingUpdate:
      maxSurge: 1000
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: time2code
        component: powershell
    spec:
      containers:
      - env:
        - name: fprocess
          value: python3 time2powershell.py
        - name: https_proxy
          value: $https_proxy
        - name: no_proxy
          value: gateway
        - name: read_timeout
          value: "60"
        - name: write_timeout
          value: "60"
        image: jockdarock/time2powershell:latest
        imagePullPolicy: Always
        name: powershell
        volumeMounts: null
      volumes: null
      nodename: aci-connector

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: prometheus
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: prometheus
    spec:
      containers:
      - name: prometheus
        image: functions/prometheus:latest-k8s
        imagePullPolicy: Always
        command: ["prometheus","-config.file=/etc/prometheus/prometheus.yml", "-storage.local.path=/prometheus", "-storage.local.memory-chunks=10000", "--alertmanager.url=http://alertmanager.default:9093"]
        imagePullPolicy: Always
        ports:
        - containerPort: 9090
          protocol: TCP

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: python
spec:
  replicas: 0
  rollbackTo:
    revision: 0
  selector:
    matchLabels:
      app: time2code
      component: python
  strategy:
    rollingUpdate:
      maxSurge: 1000
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: time2code
        component: python
    spec:
      containers:
      - env:
        - name: fprocess
          value: python3 time2py.py
        - name: https_proxy
          value: $https_proxy
        - name: no_proxy
          value: gateway
        - name: read_timeout
          value: "60"
        - name: write_timeout
          value: "60"
        image: jockdarock/time2py:latest
        imagePullPolicy: Always
        name: python
        volumeMounts: null
      volumes: null
      nodename: aci-connector

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: time2codeserver
spec:
  replicas: 3
  rollbackTo:
    revision: 0
  selector:
    matchLabels:
      app: time2code
      component: time2codeserver
  strategy:
    rollingUpdate:
      maxSurge: 10
      maxUnavailable: 2
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: time2code
        component: time2codeserver
    spec:
      containers:
      - image: jockdarock/time2codeserver:latest
        name: time2codeserver
        imagePullPolicy: Always
        env:
        - name: time2code_provider_url
          value: "http://time2codeserver.default:5555"
        ports:
        - containerPort: 5555
          protocol: TCP
        volumeMounts: null
      restartPolicy: Always
      volumes: null

================================================
FILE: k8s_templates/faas_function_k8s.yml
================================================
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: csharp-experimental
spec:
  replicas: 0
  rollbackTo:
    revision: 0
  selector:
    matchLabels:
      app: time2code
      component: csharp-experimental
  strategy:
    rollingUpdate:
      maxSurge: 1000
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: time2code
        component: csharp-experimental
    spec:
      containers:
      - env:
        - name: fprocess
          value: python3 time2CSharp.py
        - name: https_proxy
          value: $https_proxy
        - name: no_proxy
          value: gateway
        - name: read_timeout
          value: "60"
        - name: write_timeout
          value: "60"
        image: jockdarock/time2csharp:latest
        imagePullPolicy: Always
        name: csharp-experimental
      nodeSelector:
        dedicated: aci-connector

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: golang
spec:
  replicas: 1
  rollbackTo:
    revision: 0
  selector:
    matchLabels:
      app: time2code
      component: golang
  strategy:
    rollingUpdate:
      maxSurge: 1000
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: time2code
        component: golang
    spec:
      containers:
      - env:
        - name: fprocess
          value: python3 time2go.py
        - name: https_proxy
          value: $https_proxy
        - name: no_proxy
          value: gateway
        - name: read_timeout
          value: "60"
        - name: write_timeout
          value: "60"
        image: jockdarock/time2go:latest
        imagePullPolicy: Always
        name: golang
      nodeSelector:
        dedicated: aci-connector

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nodejs
spec:
  replicas: 0
  rollbackTo:
    revision: 0
  selector:
    matchLabels:
      app: time2code
      component: nodejs
  strategy:
    rollingUpdate:
      maxSurge: 1000
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: time2code
        component: nodejs
    spec:
      containers:
      - env:
        - name: fprocess
          value: python3 time2nodejs.py
        - name: https_proxy
          value: $https_proxy
        - name: no_proxy
          value: gateway
        - name: read_timeout
          value: "60"
        - name: write_timeout
          value: "60"
        image: jockdarock/time2nodejs:latest
        imagePullPolicy: Always
        name: nodejs
      nodeSelector:
        dedicated: aci-connector

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: powershell
spec:
  replicas: 0
  rollbackTo:
    revision: 0
  selector:
    matchLabels:
      app: time2code
      component: powershell
  strategy:
    rollingUpdate:
      maxSurge: 1000
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: time2code
        component: powershell
    spec:
      containers:
      - env:
        - name: fprocess
          value: python3 time2powershell.py
        - name: https_proxy
          value: $https_proxy
        - name: no_proxy
          value: gateway
        - name: read_timeout
          value: "60"
        - name: write_timeout
          value: "60"
        image: jockdarock/time2powershell:latest
        imagePullPolicy: Always
        name: powershell
        volumeMounts: null
      volumes: null
      nodeSelector:
        dedicated: aci-connector

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: python
spec:
  replicas: 0
  rollbackTo:
    revision: 0
  selector:
    matchLabels:
      app: time2code
      component: python
  strategy:
    rollingUpdate:
      maxSurge: 1000
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: time2code
        component: python
    spec:
      containers:
      - env:
        - name: fprocess
          value: python3 time2py.py
        - name: https_proxy
          value: $https_proxy
        - name: no_proxy
          value: gateway
        - name: read_timeout
          value: "60"
        - name: write_timeout
          value: "60"
        image: jockdarock/time2py:latest
        imagePullPolicy: Always
        name: python
        volumeMounts: null
      volumes: null
      nodeSelector:
        dedicated: aci-connector

================================================
FILE: k8s_templates/str8_k8s.yml
================================================
apiVersion: v1
kind: Service
metadata:
  name: time2codeserver
spec:
  type: LoadBalancer
  ports:
  - name: time2codeserver-5555
    port: 5555
    protocol: TCP
    targetPort: 5555
  selector:
    app: time2codeserver
    component: time2codeserver

---
apiVersion: v1
kind: Service
metadata:
  name: gateway
  labels:
    app: gateway
spec:
  type: LoadBalancer
  ports:
    - port: 8080
      protocol: TCP
      targetPort: 8080
  selector:
    app: gateway
---
apiVersion: v1
kind: Service
metadata:
  name: faas-netesd
  labels:
    app: faas-netesd
spec:
  type: LoadBalancer
  ports:
    - port: 8080
      protocol: TCP
      targetPort: 8080
  selector:
    app: faas-netesd
---
apiVersion: v1
kind: Service
metadata:
  name: prometheus
  labels:
    app: prometheus
spec:
  type: LoadBalancer
  ports:
    - port: 9090
      protocol: TCP
      targetPort: 9090
  selector:
    app: prometheus
---
apiVersion: v1
kind: Service
metadata:
  name: alertmanager
  labels:
    app: alertmanager
spec:
  type: LoadBalancer
  ports:
    - port: 9093
      protocol: TCP
      targetPort: 9093
  selector:
    app: alertmanager



---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: time2codeserver
spec:
  replicas: 3
  rollbackTo:
    revision: 0
  selector:
    matchLabels:
      app: time2codeserver
      component: time2codeserver
  strategy:
    rollingUpdate:
      maxSurge: 3
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: time2codeserver
        component: time2codeserver
    spec:
      containers:
      - image: jockdarock/time2codeserver:latest
        name: time2codeserver
        imagePullPolicy: Always
        env:
        - name: time2code_provider_url
          value: "http://time2codeserver.default.svc.cluster.local:5555"
        ports:
        - containerPort: 5555
          protocol: TCP
      restartPolicy: Always
---
apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1
kind: Deployment
metadata:
  name: faas-netesd
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: faas-netesd
    spec:
      containers:
      - name: faas-netesd
        image: functions/faas-netesd:0.3.4
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
          protocol: TCP
---
apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1
kind: Deployment
metadata:
  name: gateway
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: gateway
    spec:
      containers:
      - name: gateway
        image: functions/gateway:0.6.13
        imagePullPolicy: Always
        env:
        - name: functions_provider_url
          value: "http://faas-netesd.default.svc.cluster.local:8080/"
        ports:
        - containerPort: 8080
          protocol: TCP
---
apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1
kind: Deployment
metadata:
  name: prometheus
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: prometheus
    spec:
      containers:
      - name: prometheus
        image: functions/prometheus:latest-k8s
        command: ["prometheus","-config.file=/etc/prometheus/prometheus.yml", "-storage.local.path=/prometheus", "-storage.local.memory-chunks=10000", "--alertmanager.url=http://alertmanager.default:9093"]
        imagePullPolicy: Always
        ports:
        - containerPort: 9090
          protocol: TCP
---
apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1
kind: Deployment
metadata:
  name: alertmanager
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: alertmanager
    spec:
      containers:
      - name: alertmanager
        image: functions/alertmanager:latest-k8s
        imagePullPolicy: Always
        command: ["/bin/alertmanager","-config.file=/alertmanager.yml", "-storage.path=/alertmanager"]
        ports:
        - containerPort: 9003
          protocol: TCP
---


================================================
FILE: minikube.sh
================================================
#! /bin/bash

git clone https://github.com/alexellis/faas-netes

curl -sSL cli.get-faas.com | sudo sh

kubectl apply -f faas-netes/faas.yml,faas-netes/monitoring.yml,./time2code-server-k8s.yml

sed "s/localhost:31112/$(minikube ip):31112/" time2code-faas-cli-functions.yml > .time2code-faas-cli-minikube.yml

echo "Load the Code execution Functions with the faas-cli and then navigate to this site http://$(minikube ip):31114 in your favorite browser."


================================================
FILE: templates/alloy_server.html
================================================
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Base Test Une</title>
    <script src="http://cdn.alloyui.com/3.0.1/aui/aui-min.js"></script>
    <link href="http://cdn.alloyui.com/3.0.1/aui-css/css/bootstrap.min.css" rel="stylesheet"></link>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>
<body>
    <div id="myWrapper">
      <form class="form">
        <div class="form-group">
          <label for="mode" class="control-label">Language Mode:</label>
          <select id="mode" class="form-control">
            <option>python</option>
            <option>json</option>
            <option>golang</option>
          </select>
        </div>
      </form>
      <div id="myEditor"></div>
    </div>
    <script>
        YUI().use(
          'aui-ace-autocomplete-base',
          function(Y) {
            var editor = new Y.AceEditor(
              {
                boundingBox: '#myEditor',
                height: '200',
                mode: 'python',
                value: 'print("Hello there!!!")',
                width: '700',
                theme: 'chaos'
              }
            ).render();
            editor.ace.config.set('themPath

            var mode = Y.one('#mode');

            if (mode) {
              var contents = {
                python: 'print("Hello there!!!")',
                golang: 'package main\r\n\r\nimport "fmt"\r\n\r\nfunc main(){\r\n\r\t\r\t}',
                json: '{"value": "Write something here..."}'
              };

              var currentMode = 'python';

              var updateValue = function() {
                editor.set('value', contents[currentMode]);
              };

              mode.on(
                'change',
                function(event) {
                  currentMode = this.val();
                  editor.set('mode', currentMode);
                  updateValue();
                }
              );
            }
          }
        );
    </script>

</body>
</html>

================================================
FILE: templates/base_test.html
================================================
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Base Test Une</title>
    <script src="https://cdn.rawgit.com/ajaxorg/ace-builds/812e2c56aed246931a667f16c28b096e34597016/src/ace.js" type="text/javascript"></script>

</head>
<body>
    <style type="text/css">
        #IDE {
            position: absolute;
            width: 100%;
            height: 85%;
            background-color:black;
        }
        #button {
            position:relative;
            transition: .5s ease;
            top: 550px;
            left: 33%;

            z-index: 99999;
        }
    </style>
    <div id="IDE">

    </div>
    <script>
        var IDE = ace.edit("IDE");
        IDE.setTheme("ace/theme/chaos");
        IDE.session.setMode("ace/mode/python")
    </script>
    <div>
        <button id="button">RUN</button>
    </div>
    <div id="console" class="ui-widget-content"></div>
    <style>
        /* The console container element */
        #console {
          position: absolute;
          width: 400px;
          height: 500px;
          background-color:black;
          z-index: 99990;
          right: 15px;
        }
        /* The inner console element. */
        .jqconsole {
            padding: 10px;
        }
        /* The cursor. */
        .jqconsole-cursor {
            background-color: gray;
        }
        /* The cursor color when the console looses focus. */
        .jqconsole-blurred .jqconsole-cursor {
            background-color: #666;
        }
        /* The current prompt text color */
        .jqconsole-prompt {
            color: #0d0;
        }
        /* The command history */
        .jqconsole-old-prompt {
            color: #0b0;
            font-weight: normal;
        }
        /* The text color when in input mode. */
        .jqconsole-input {
            color: #dd0;
        }
        /* Previously entered input. */
        .jqconsole-old-input {
            color: #bb0;
            font-weight: normal;
        }
        /* The text color of the output. */
        .jqconsole-output {
            color: white;
        }
    </style>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="https://cdn.rawgit.com/replit/jq-console/master/lib/jqconsole.js" type="text/javascript" charset="utf-8"></script>
    <script>


      $(document).ready(function(){
            var jqconsole = $('#console').jqconsole('>>>\n');
            $("button").click(function(){
                jqconsole.Reset();
                var IDE = ace.edit("IDE");
                var code = IDE.getValue();
                var url = "http://" + location.hostname + ":8080/function/{{ code_exec }}";
                console.log(url)
                $.ajax({
                    url: url,
                    type: 'post',
                    dataType: 'text',
                    headers: {'Content-Type': 'text/plain'},
                    // data: "print('hey')",
                    data: code,
                    success: function (data) {
                        console.log(data);
                        $(function () {
                            var writePrompt = function () {
                                jqconsole.Prompt(false);
                                jqconsole.Write(data + '\n', 'jqconsole-output');
                              // Start the prompt with history enabled.
                              // jqconsole.Prompt(false, function (input) {
                                // Output input with the class jqconsole-output.
                                //jqconsole.Write(input + '\n', 'jqconsole-output');
                                // Restart the prompt.
                                //startPrompt();
                              };
                            writePrompt();
                        });
                    },
                });
            });
        });
    </script>

</body>
</html>

================================================
FILE: templates/base_test_server.html
================================================
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Base Test Une</title>
    <script src="https://cdn.rawgit.com/ajaxorg/ace-builds/812e2c56aed246931a667f16c28b096e34597016/src/ace.js" type="text/javascript"></script>

</head>
<body>
    <style type="text/css">
        #IDE {
            position: absolute;
            width: 100%;
            height: 85%;
            background-color:black;
        }
        #button {
            position:relative;
            transition: .5s ease;
            top: 550px;
            left: 33%;

            z-index: 99999;
        }
    </style>
    <div id="IDE">

    </div>
    <script>
        var IDE = ace.edit("IDE");
        IDE.setTheme("ace/theme/chaos");
        IDE.session.setMode("ace/mode/python")
    </script>
    <div>
        <button id="button">RUN</button>
    </div>
    <div id="console" class="ui-widget-content"></div>
    <style>
        /* The console container element */
        #console {
          position: absolute;
          width: 400px;
          height: 500px;
          background-color:black;
          z-index: 99990;
          right: 15px;
        }
        /* The inner console element. */
        .jqconsole {
            padding: 10px;
        }
        /* The cursor. */
        .jqconsole-cursor {
            background-color: gray;
        }
        /* The cursor color when the console looses focus. */
        .jqconsole-blurred .jqconsole-cursor {
            background-color: #666;
        }
        /* The current prompt text color */
        .jqconsole-prompt {
            color: #0d0;
        }
        /* The command history */
        .jqconsole-old-prompt {
            color: #0b0;
            font-weight: normal;
        }
        /* The text color when in input mode. */
        .jqconsole-input {
            color: #dd0;
        }
        /* Previously entered input. */
        .jqconsole-old-input {
            color: #bb0;
            font-weight: normal;
        }
        /* The text color of the output. */
        .jqconsole-output {
            color: white;
        }
    </style>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="https://cdn.rawgit.com/replit/jq-console/8baeef38/lib/jqconsole.js" type="text/javascript" charset="utf-8"></script>
    <script>


      $(document).ready(function(){
            var jqconsole = $('#console').jqconsole('>>>\n');
            $("button").click(function(){
                jqconsole.Reset();
                var IDE = ace.edit("IDE");
                var code = IDE.getValue();
                var url = "http://" + location.host + "/code/{{ code_exec }}";
                console.log(url)
                $.ajax({
                    url: url,
                    type: 'post',
                    dataType: 'text',
                    headers: {'Content-Type': 'text/plain'},
                    // data: "print('hey')",
                    data: code,
                    success: function (data) {
                        console.log(data);
                        $(function () {
                            var writePrompt = function () {
                                jqconsole.Prompt(false);
                                jqconsole.Write(data + '\n', 'jqconsole-output');
                              // Start the prompt with history enabled.
                              // jqconsole.Prompt(false, function (input) {
                                // Output input with the class jqconsole-output.
                                //jqconsole.Write(input + '\n', 'jqconsole-output');
                                // Restart the prompt.
                                //startPrompt();
                              };
                            writePrompt();
                        });
                    },
                });
            });
        });
    </script>

</body>
</html>

================================================
FILE: templates/boostrap_server.html
================================================
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="https://cdn.rawgit.com/ajaxorg/ace-builds/812e2c56aed246931a667f16c28b096e34597016/src/ace.js" type="text/javascript"></script>
</head>
<body>

<div class="container-fluid">
  <h1>Hello World!</h1>
  <p>Resize the browser window to see the effect.</p>
  <div class="row">
    <style>
        #code-instruct {
            height: 500px;
        }
    </style>
    <div id="code-instruc" class="col-lg-4">
        {{ markd }}
    </div>
            <div class="col-lg-4">
                <div class="panel panel-defaults"
                    <div id="IDE-header" class="panel-heading">
                        <h3 class="panel-title">Editor</h3>
                    </div>
                    <div id="IDE-body" class="panel-body">
                        <style type="text/css">
                            #IDE {
                                height: 500px;
                                background-color:black;
                            }

                            #IDE-header {
                                background-color:black;
                            }
                            #IDE-body {
                                background-color:black;
                            }
                        </style>
                        <div id="IDE">print("Hello")</div>
                        <script>
                            var IDE = ace.edit("IDE");
                            IDE.setTheme("ace/theme/chaos");
                            IDE.session.setMode("ace/mode/python")
                        </script>
                    </div>
                </div>
            </div>


            <div class="col-lg-4">
                <div class="panel panel-defaults">
                    <div id="console-body" class="panel-body">
                        <div id="console" class="ui-widget-content"></div>
                            <style>
                                /* The console container element */
                                #console {
                                  height: 500px;
                                  background-color:black;
                                }
                                #console-body {
                                  background-color:black;
                                }
                                /* The inner console element. */
                                .jqconsole {
                                    padding: 10px;
                                }
                                /* The cursor. */
                                .jqconsole-cursor {
                                    background-color: gray;
                                }
                                /* The cursor color when the console looses focus. */
                                .jqconsole-blurred .jqconsole-cursor {
                                    background-color: #666;
                                }
                                /* The current prompt text color */
                                .jqconsole-prompt {
                                    color: #0d0;
                                }
                                /* The command history */
                                .jqconsole-old-prompt {
                                    color: #0b0;
                                    font-weight: normal;
                                }
                                /* The text color when in input mode. */
                                .jqconsole-input {
                                    color: #dd0;
                                }
                                /* Previously entered input. */
                                .jqconsole-old-input {
                                    color: #bb0;
                                    font-weight: normal;
                                }
                                /* The text color of the output. */
                                .jqconsole-output {
                                    color: white;
                                }
                            </style>
                            <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js" type="text/javascript" charset="utf-8"></script>
                            <script src="https://cdn.rawgit.com/replit/jq-console/8baeef38/lib/jqconsole.js" type="text/javascript" charset="utf-8"></script>
                            <script>


                              $(document).ready(function(){
                                    var jqconsole = $('#console').jqconsole('>>>\n');
                                    $("button").click(function(){
                                        jqconsole.Reset();
                                        var IDE = ace.edit("IDE");
                                        var code = IDE.getValue();
                                        var url = "http://" + location.host + "/code/{{ code_exec }}";
                                        console.log(url)
                                        $.ajax({
                                            url: url,
                                            type: 'post',
                                            dataType: 'text',
                                            headers: {'Content-Type': 'text/plain'},
                                            // data: "print('hey')",
                                            data: code,
                                            success: function (data) {
                                                console.log(data);
                                                $(function () {
                                                    var writePrompt = function () {
                                                        jqconsole.Prompt(false);
                                                        jqconsole.Write(data + '\n', 'jqconsole-output');
                                                      // Start the prompt with history enabled.
                                                      // jqconsole.Prompt(false, function (input) {
                                                        // Output input with the class jqconsole-output.
                                                        //jqconsole.Write(input + '\n', 'jqconsole-output');
                                                        // Restart the prompt.
                                                        //startPrompt();
                                                      };
                                                    writePrompt();
                                                });
                                            },
                                        });
                                    });
                                });
                            </script>
                    </div>
                </div>
            </div>


  </div>
</div>

</body>
</html>

================================================
FILE: templates/index-panel.html
================================================
<html>

  <head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- UI based on the Play-With-Moby site and by the team at Play-With-Docker and the learning experiences they deliver everyday -->


<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/darkly/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic">
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.8/ace.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdn.rawgit.com/replit/jq-console/8baeef38/lib/jqconsole.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xterm/2.8.1/xterm.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/xterm/2.8.1/xterm.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xterm/2.8.1/addons/fit/fit.js"></script>

<style>
    html, body {
        height: 100%;
        background-color: #052f47;
        color: #fff
    }
    img {
        max-width: 100%
    }
    .mt50 {
        margin-top: 50px
    }
    .mt20 {
        margin-top: 20px
    }
    .mt10 {
        margin-top: 10px
    }
    .mb10 {
        margin-bottom: 10px
    }
    body {
        display: flex;
        flex-direction: column
    }
    body>* {
        flex: none
    }
    #IDE {
        background-color: #24323a
    }
    #terminal {
        height: 100%;
    }
    .navbar-header {
        margin-top: 5px
    }
    .navbar-header button {
        margin-left: 10px
    }
    .navbar-header input {
        color: #000;
        margin-left: 5px;
        width: 300px;
        display: none
    }
    .navbar {
        border-radius: 0px;
        margin-bottom: 0px
    }
    .navbar.navbar-inverse {
        background-color: #052f47;
        border-color: #052f47
    }
    .navbar.navbar-inverse a, .navbar.navbar-inverse .navbar-nav li a {
        color: #fff
    }
    .navbar.navbar-inverse a:hover, .navbar.navbar-inverse .navbar-nav li a:hover {
        text-decoration: underline
    }
    footer {
        background-color: #052f47
    }
    .navbar-brand {
        font-weight: 900;
        margin-left: 0px !important;
        vertical-align: middle;
        float: none
    }
    @media screen and (max-width: 600px) {
        .navbar-brand {
            font-size: 1.5em
        }
    }
    .panel {
        border: none;
        box-shadow: 0px 0px 1px #828282
    }
    .panel:hover {
        box-shadow: 0px 0px 6px #828282
    }
    .social {
        list-style: none;
        display: inline;
        margin-left: 10px;
        padding: 5px 8px
    }
    .social:hover {
        opacity: 0.7
    }
    .social img {
        width: 20px
    }
    .quora img {
        width: 17px
    }
    .facebook img {
        width: 16px
    }
    .panel-container {
        display: flex;
        flex-direction: row;
        overflow: hidden;
        height: 100%;
        flex: 1 1 auto;
        xtouch-action: none
    }
    .terminal {
        font-size: 15px
    }
    .panel-left, IDE {
        flex: 0 0 auto;
        width: 50%;
        min-width: 150px
    }
    .content {
        padding: 0 15px;
        overflow-y: auto
    }
    .content {
        padding: 0 15px
    }
    .splitter {
        flex: 0 0 auto;
        width: 18px;
        background: url(https://raw.githubusercontent.com/RickStrahl/jquery-resizable/master/assets/vsizegrip.png) center center no-repeat #101e26;
        min-height: 200px;
        cursor: col-resize
    }
    .panel-right {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        width: 100%;
        background-color: #000000
    }
    .panel-right>div {
        flex: 1 1 auto;
        margin-bottom: 15px;
        overflow-y: auto
    }
    .panel-right>div:last-of-type {
        margin-bottom: 0px
    }
    .panel-right>div.initialized {
        background-color: black
    }
    .post-tag {
        display: inline-block;
        background: rgba(42, 122, 226, 0.15);
        padding: 0 .5rem;
        margin-right: .5rem;
        border-radius: 4px;
        color: #2a7ae2;
        font-family: "Open Sans", serif;
        font-size: 90%
    }
    .post-tag:before {
        content: "\f02b";
        font-family: FontAwesome;
        padding-right: .5em
    }
    .post-tag:hover {
        text-decoration: none;
        background: #2a7ae2;
        color: #fff
    }
    small .post-tag {
        background: #eee;
        color: #000
    }
    small .post-tag:before {
        content: none
    }
    small .post-tag:hover {
        text-decoration: none;
        background: #000;
        color: #fff;
        cursor: default
    }
    .tags-expo :target:before {
        content: "";
        display: block;
        height: 72px;
        margin: -72px 0 0
    }
    @media (min-width: 38em) {
        .tags-expo .tags-expo-list {
            font-size: 2.9rem
        }
        .tags-expo .tags-expo-list .post-tag {
            margin: .2em .3em
        }
    }
    .tags-expo .tags-expo-section {
        font-family: "Open Sans", serif
    }
    .tags-expo .tags-expo-section ul {
        list-style-type: circle;
        list-style-position: inside;
        padding: 0
    }
    .tags-expo .tags-expo-section ul li {
        padding: 0 1rem
    }
    .tags-expo .tags-expo-section ul li:hover {
        list-style-type: disc
    }
    .tags-expo .tags-expo-section a {
        font-size: 20px
    }
    .tags-expo .tags-expo-section .post-date {
        display: inline-block;
        font-size: 80%;
        color: #000;
        margin: 0;
        padding: 0
    }
</style>

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
</head>
  <body>

    <header class="site-header">
<nav class="navbar navbar-default navbar-inverse">

    <div class="container">
      <div class="logo"><img src="../static/TIME2CODE-grey.png"></div>
        <div class="navbar-header">
        <!--<a class="navbar-brand" href="/">Time2Code</a>-->
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>

        </div>
  </div><!-- /.container-fluid -->
</nav>
</header>


    <div class="panel-container">
        <div class="panel-left" id="IDE"/>
    </div>

    <div class="splitter">
    </div>
    <div class="panel-right">
        <div id="terminal"></div>
          <script>

          </script>
    </div>
</div>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="https://rawgit.com/RickStrahl/jquery-resizable/master/dist/jquery-resizable.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.7/ace.js"></script>
<script>
    var IDE = ace.edit("IDE");

    IDE.setTheme("ace/theme/vibrant_ink");
    IDE.session.setMode("ace/mode/python");

    IDE.setShowPrintMargin(false);

    $(".panel-left").resizable({
        handleSelector: ".splitter",
        resizeHeight: false,
    });
</script>



  <footer>
    <nav class="navbar navbar-default">
      <div class="container-fluid">
        <ul class="nav navbar-nav">
            <li>
                <button id="code" onclick="termchange()" class="btn btn-success navbar-btn">RUN IT</button>
                <button id="code" onclick="termclear()" class="btn btn-danger navbar-btn">CLEAR TERM</button>
            </li>
            <form class="navbar-form navbar-right">
                <div class="form-group">
                  <select id="mode" class="form-control" style="float:right;">
                    <option label="python" value="python3">python3</option>
                    <option label="golang" value="golang">golang</option>
                    <option label="javascript" value="nodejs">nodejs</option>
                    <option label="fortran" value="fortran">fortran</option>
                    <option label="ruby" value="ruby">ruby</option>
                    <option label="powershell" value="powershell">powershell</option>
                    <option label="csharp" value="csharp-experimental">csharp-experimental</option>
                  </select>
                    <script>
                        document.getElementById("mode").value = "{{ code_lang }}";
                        var modeElement = document.getElementById("mode");
                        mode = modeElement.options[modeElement.selectedIndex].label;
                        var IDE = ace.edit("IDE");
                        var code = $('<textarea />').html(`{{ code_text }}`).text();
                        IDE.setValue(code, -1);
                        IDE.session.setMode("ace/mode/" + mode);
                        document.addEventListener("DOMContentLoaded", function(event){
                            $("#mode").change(function() {
                                var modeElement = document.getElementById("mode");
                                mode = modeElement.options[modeElement.selectedIndex].label;
                                console.log(mode);
                                var IDE = ace.edit("IDE");
                                IDE.setTheme("ace/theme/vibrant_ink");
                                IDE.session.setMode("ace/mode/" + mode);
                                IDE.setOption("showPrintMargin", false);
                            });
                        });
                    </script>
                </div>
            </form>
      </div>
    </nav>

</footer>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  <script>
        function sleep(ms) {
          return new Promise(resolve => setTimeout(resolve, ms));
        }

        var term = new Terminal({cursorBlink: false, rows: 40});
        term.open(document.getElementById('terminal'));

        function termchange() {
                    var getmode = document.getElementById("mode");
                    var mode = getmode.options[getmode.selectedIndex].label;
                    var mode_code = getmode.options[getmode.selectedIndex].value;
                    var IDE = ace.edit("IDE");
                    var code = IDE.getValue();
                    var url = "http://" + location.host + "/code?lang=" + mode_code;
                    console.log(url)
                    $.ajax({
                        url: url,
                        type: 'post',
                        dataType: 'text',
                        headers: {'Content-Type': 'text/plain'},
                        // data: "print('hey')",
                        data: code,
                        success: function (data) {
                            console.log(data);
                            $(function () {
                                var writePrompt = function () {
                                    var termData = data.replace(/\r?\n/g, "\r\n");
                                    term.writeln(termData);
                                  };
                                writePrompt();
                                term.scrollToBottom();
                            });
                        },
                    });

                };

        async function termclear() {
            term.destroy();
            await sleep(100);
            term = new Terminal({cursorBlink: false, rows: 40});
            term.open(document.getElementById('terminal'));
        };
    </script>



  </body>

</html>

================================================
FILE: templates/index-tut.html
================================================
<html>

  <head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- UI based on the Play-With-Moby site and by the team at Play-With-Docker and the learning experiences they deliver everyday -->


<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/darkly/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic">
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.8/ace.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdn.rawgit.com/replit/jq-console/8baeef38/lib/jqconsole.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xterm/2.8.1/xterm.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/xterm/2.8.1/xterm.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xterm/2.8.1/addons/fit/fit.js"></script>
<script src="https://cdn.rawgit.com/showdownjs/showdown/<version tag>/dist/showdown.min.js"></script>

<style>
    html, body {
        height: 100%;
        background-color: #24323a;
        color: #fff;
        overflow: auto;
    }
    body {
        display: flex;
        flex-direction: column
    }
    body>* {
        flex: none
    }
    #window {
        margin: 0;
        width: 100%;
        height: 100%;
    }
    #IDE {
        background-color: #000000;
    }
    #tutorial {
        padding-top: 25px;
        padding-right: 25px;
        padding-bottom: 25px;
        padding-left: 25px;
    }
    #terminal {
        height: 75%;
        overflow: hidden;
    }
    .ace_layer ace_gutter-layer ace_folding-enabled {
        background-color: #000000;
    }
    .navbar-header {
        margin-top: 5px
    }
    .navbar-header button {
        margin-left: 10px
    }
    .navbar-header input {
        color: #000;
        margin-left: 5px;
        width: 300px;
        display: none
    }
    .navbar {
        border-radius: 0px;
        margin-bottom: 0px;
        postion: fixed;
    }
    .navbar.navbar-inverse, .navbar.navbar-default {
        background-color: #052f47;
        border-color: #052f47
    }
    .navbar.navbar-inverse a, .navbar.navbar-inverse .navbar-nav li a {
        color: #fff
    }
    .navbar.navbar-inverse a:hover, .navbar.navbar-inverse .navbar-nav li a:hover {
        text-decoration: underline
    }
    footer {
        background-color: #052f47;
        position: fixed;
        bottom: 0;
        width: 100%;
    }
    .navbar-brand {
        font-weight: 900;
        margin-left: 0px !important;
        vertical-align: middle;
        float: none
    }
    .panel {
        border: none;
        box-shadow: 0px 0px 1px #828282
    }
    .panel:hover {
        box-shadow: 0px 0px 6px #828282
    }
    .panel-container-vertical {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }
    .panel-top {
        flex: 0 0 auto;
        height: 50%;
        width: 100%;
    }
    .panel-bottom {
        flex: 1 1 auto;
        background-color: #000000;
    }
    .panel-container {
        display: flex;
        flex-direction: row;
        overflow: hidden;
        height: 100%;
        xtouch-action: none;
    }
    .terminal {
        font-size: 15px
    }
    .panel-left {
        flex: 0 0 auto;
        width: 50%;
        min-width: 150px;
    }
    .splitter {
        flex: 0 0 auto;
        width: 18px;
        background: url(https://raw.githubusercontent.com/RickStrahl/jquery-resizable/master/assets/vsizegrip.png) center center no-repeat #101e26;
        min-height: 200px;
        cursor: col-resize;
    }
    .splitter-horizontal {
        flex: 0 0 auto;
        height: 5px;
        background: url(https://raw.githubusercontent.com/RickStrahl/jquery-resizable/master/assets/hsizegrip.png) center center no-repeat #101e26;
        cursor: row-resize;
    }
    .panel-right {
        flex: 1 1 auto;
        width: 100%;
        background: #24323a
    }
    .pagination {
        clear:both;
        position:relative;
        text-align:center;
    }
    .center {
        text-align: center;
    }
</style>

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
</head>
  <body>

    <header class="site-header">

</header>
<nav class="navbar navbar-default navbar-inverse">

    <div class="container">
      <div class="logo"><img src="/static/TIME2CODE-grey.png"></div>
        <div class="navbar-header">
        <!--<a class="navbar-brand" href="/">Time2Code</a>-->
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>

        </div>
  </div><!-- /.container-fluid -->
</nav>
    <div class="panel-container-vertical">
    <div class="panel-container">

        <div class="panel-left" style="overflow:auto;">

                <div id="tutorial">{{ markdown }}</div>
                <div class="center" hidden><ul class="pagination" id="buttons">
                    <li><a href="#">«</a></li>
                    <li><a href="#">1</a></li>
                    <li><a href="#">2</a></li>
                    <li><a href="#">3</a></li>
                    <li><a href="#">4</a></li>
                    <li><a href="#">5</a></li>
                    <li><a href="#">6</a></li>
                    <li><a href="#">»</a></li>
                </ul></div>

        </div>

        <div class="splitter">
        </div>

        <div class="panel-right" >
            <div class="panel-top" id="IDE">{{ code_text }}</div>

            <div class="splitter-horizontal">
            </div>

            <div class="panel-bottom">
                <div id="terminal">
                </div>
            </div>
        </div>
      </div>

    </div>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="https://rawgit.com/RickStrahl/jquery-resizable/master/dist/jquery-resizable.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.7/ace.js"></script>
<script>
    var IDE = ace.edit("IDE");

    IDE.setTheme("ace/theme/vibrant_ink");
    IDE.session.setMode("ace/mode/python");

    IDE.setShowPrintMargin(false);

    $(".panel-left").resizable({
        handleSelector: ".splitter",
        resizeHeight: false,
    });
</script>

  <footer>
    <nav class="navbar navbar-default">
      <div class="container-fluid">
        <ul class="nav navbar-nav">
            <li>
                <button id="code" onclick="termchange()" class="btn btn-success navbar-btn">RUN IT</button>
                <button id="code" onclick="termclear()" class="btn btn-danger navbar-btn">CLEAR TERM</button>
            </li>
            <form class="navbar-form navbar-right">
                <div class="form-group">
                  <select id="mode" class="form-control" style="float:right;">
                    <option label="python" value="python3">python3</option>
                    <option label="golang" value="golang">golang</option>
                    <option label="javascript" value="nodejs">nodejs</option>
                    <option label="fortran" value="fortran">fortran</option>
                    <option label="ruby" value="ruby">ruby</option>
                    <option label="powershell" value="powershell">powershell</option>
                    <option label="csharp" value="csharp-experimental">csharp-experimental</option>
                  </select>
                    <script>
                        document.getElementById("mode").value = "{{ code_lang }}";
                        var modeElement = document.getElementById("mode");
                        mode = modeElement.options[modeElement.selectedIndex].label;
                        var IDE = ace.edit("IDE");
                        IDE.session.setMode("ace/mode/" + mode);
                        var code = $('<textarea />').html(`{{ code_text }}`).text();
                        IDE.setValue(code, -1);
                        document.addEventListener("DOMContentLoaded", function(event){
                            $("#mode").change(function() {
                                var modeElement = document.getElementById("mode");
                                mode = modeElement.options[modeElement.selectedIndex].label;
                                console.log(mode);
                                var IDE = ace.edit("IDE");
                                IDE.setTheme("ace/theme/vibrant_ink");
                                IDE.session.setMode("ace/mode/" + mode);
                                IDE.setOption("showPrintMargin", false);
                            });
                        });



                    </script>
                </div>
            </form>
        </ul>
      </div>
    </nav>

</footer>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  <script>
        function sleep(ms) {
          return new Promise(resolve => setTimeout(resolve, ms));
        }

        Terminal.loadAddon('fit');
        var term = new Terminal({cursorBlink: false, rows: 12});
        term.open(document.getElementById('terminal'));

        async function termclear() {
            term.destroy();
            await sleep(100);
            term = new Terminal({cursorBlink: false, rows: 12});
            term.open(document.getElementById('terminal'));
        };

        function termchange() {
                    var getmode = document.getElementById("mode");
                    var mode = getmode.options[getmode.selectedIndex].label;
                    var mode_code = getmode.options[getmode.selectedIndex].value;
                    var IDE = ace.edit("IDE");
                    var code = IDE.getValue();
                    var url = "http://" + location.host + "/code?lang=" + mode_code;
                    console.log(url);
                    termclear()
                    $.ajax({
                        url: url,
                        type: 'post',
                        dataType: 'text',
                        headers: {'Content-Type': 'text/plain'},
                        // data: "print('hey')",
                        data: code,
                        success: function (data) {
                            console.log(data);
                            $(function () {
                                var writePrompt = function () {
                                    var termData = data.replace(/\r?\n/g, "\r\n");
                                    term.writeln(termData);
                                  };
                                writePrompt();
                                term.scrollToBottom();
                            });
                        },
                    });

                };


        $("pre").each(function() {
            $(this).click(function() {
                console.log($(this).text());
                document.execCommand("copy");
                var IDE = ace.edit("IDE");
                var code = $('<textarea />').html($(this).text()).text();
                IDE.setValue(code, -1);
            })
        });
    </script>



  </body>

</html>

================================================
FILE: templates/index-tutorial.html
================================================
<html>

  <head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- UI based on the Play-With-Moby site and by the team at Play-With-Docker and the learning experiences they deliver everyday -->


<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/darkly/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic">
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.8/ace.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdn.rawgit.com/replit/jq-console/8baeef38/lib/jqconsole.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xterm/2.8.1/xterm.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/xterm/2.8.1/xterm.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xterm/2.8.1/addons/fit/fit.js"></script>
<script src="https://cdn.rawgit.com/showdownjs/showdown/<version tag>/dist/showdown.min.js"></script>

<style>
    html, body {
        height: 100%;
        background-color: #24323a;
        color: #fff;
        overflow: auto;
    }
    body {
        display: flex;
        flex-direction: column
    }
    body>* {
        flex: none
    }
    #window {
        margin: 0;
        width: 100%;
        height: 100%;
    }
    #IDE {
        background-color: #000000;
    }
    #tutorial {
        padding-top: 25px;
        padding-right: 25px;
        padding-bottom: 25px;
        padding-left: 25px;
    }
    #terminal {
        height: 75%;
        overflow: hidden;
    }
    .ace_layer ace_gutter-layer ace_folding-enabled {
        background-color: #000000;
    }
    .navbar-header {
        margin-top: 5px
    }
    .navbar-header button {
        margin-left: 10px
    }
    .navbar-header input {
        color: #000;
        margin-left: 5px;
        width: 300px;
        display: none
    }
    .navbar {
        border-radius: 0px;
        margin-bottom: 0px;
        postion: fixed;
    }
    .navbar.navbar-inverse, .navbar.navbar-default {
        background-color: #052f47;
        border-color: #052f47
    }
    .navbar.navbar-inverse a, .navbar.navbar-inverse .navbar-nav li a {
        color: #fff
    }
    .navbar.navbar-inverse a:hover, .navbar.navbar-inverse .navbar-nav li a:hover {
        text-decoration: underline
    }
    footer {
        background-color: #052f47;
        position: fixed;
        bottom: 0;
        width: 100%;
    }
    .navbar-brand {
        font-weight: 900;
        margin-left: 0px !important;
        vertical-align: middle;
        float: none
    }
    .panel {
        border: none;
        box-shadow: 0px 0px 1px #828282
    }
    .panel:hover {
        box-shadow: 0px 0px 6px #828282
    }
    .panel-container-vertical {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }
    .panel-top {
        flex: 0 0 auto;
        height: 50%;
        width: 100%;
    }
    .panel-bottom {
        flex: 1 1 auto;
        background-color: #000000;
    }
    .panel-container {
        display: flex;
        flex-direction: row;
        overflow: hidden;
        height: 100%;
        xtouch-action: none;
    }
    .terminal {
        font-size: 15px
    }
    .panel-left {
        flex: 0 0 auto;
        width: 50%;
        min-width: 150px;
    }
    .splitter {
        flex: 0 0 auto;
        width: 18px;
        background: url(https://raw.githubusercontent.com/RickStrahl/jquery-resizable/master/assets/vsizegrip.png) center center no-repeat #101e26;
        min-height: 200px;
        cursor: col-resize;
    }
    .splitter-horizontal {
        flex: 0 0 auto;
        height: 5px;
        background: url(https://raw.githubusercontent.com/RickStrahl/jquery-resizable/master/assets/hsizegrip.png) center center no-repeat #101e26;
        cursor: row-resize;
    }
    .panel-right {
        flex: 1 1 auto;
        width: 100%;
        background: #24323a
    }
    .pagination {
        clear:both;
        position:relative;
        text-align:center;
    }
    .center {
        text-align: center;
    }
</style>

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
</head>
  <body>

    <header class="site-header">

</header>
<nav class="navbar navbar-default navbar-inverse">

    <div class="container">
      <div class="logo"><img src="/static/TIME2CODE-grey.png"></div>
        <div class="navbar-header">
        <!--<a class="navbar-brand" href="/">Time2Code</a>-->
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>

        </div>
  </div><!-- /.container-fluid -->
</nav>
    <div class="panel-container-vertical">
    <div class="panel-container">

        <div class="panel-left" style="overflow:auto;">

                <div id="tutorial">{{ markdown }}</div>
                <div class="center" hidden><ul class="pagination" id="buttons">
                    <li><a href="#">«</a></li>
                    <li><a href="#">1</a></li>
                    <li><a href="#">2</a></li>
                    <li><a href="#">3</a></li>
                    <li><a href="#">4</a></li>
                    <li><a href="#">5</a></li>
                    <li><a href="#">6</a></li>
                    <li><a href="#">»</a></li>
                </ul></div>

        </div>

        <div class="splitter">
        </div>

        <div class="panel-right" >
            <div class="panel-top" id="IDE">{{ code_text }}</div>

            <div class="splitter-horizontal">
            </div>

            <div class="panel-bottom">
                <div id="terminal">
                </div>
            </div>
        </div>
      </div>

    </div>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="https://rawgit.com/RickStrahl/jquery-resizable/master/dist/jquery-resizable.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.7/ace.js"></script>
<script>
    var IDE = ace.edit("IDE");

    IDE.setTheme("ace/theme/vibrant_ink");
    IDE.session.setMode("ace/mode/python");

    IDE.setShowPrintMargin(false);

    $(".panel-left").resizable({
        handleSelector: ".splitter",
        resizeHeight: false,
    });
</script>

  <footer>
    <nav class="navbar navbar-default">
      <div class="container-fluid">
        <ul class="nav navbar-nav">
            <li>
                <button id="code" onclick="termchange()" class="btn btn-success navbar-btn">RUN IT</button>
                <button id="code" onclick="termclear()" class="btn btn-danger navbar-btn">CLEAR TERM</button>
            </li>
            <form class="navbar-form navbar-right">
                <div class="form-group">
                  <select id="mode" class="form-control" style="float:right;">
                    <option label="python" value="python3">python3</option>
                    <option label="golang" value="golang">golang</option>
                    <option label="javascript" value="nodejs">nodejs</option>
                    <option label="fortran" value="fortran">fortran</option>
                    <option label="ruby" value="ruby">ruby</option>
                    <option label="powershell" value="powershell">powershell</option>
                    <option label="csharp" value="csharp-experimental">csharp-experimental</option>
                  </select>
                    <script>
                        document.getElementById("mode").value = "{{ code_lang }}";
                        var modeElement = document.getElementById("mode");
                        mode = modeElement.options[modeElement.selectedIndex].label;
                        var IDE = ace.edit("IDE");
                        IDE.session.setMode("ace/mode/" + mode);
                        var code = $('<textarea />').html(`{{ code_text }}`).text();
                        IDE.setValue(code, -1);
                        document.addEventListener("DOMContentLoaded", function(event){
                            $("#mode").change(function() {
                                var modeElement = document.getElementById("mode");
                                mode = modeElement.options[modeElement.selectedIndex].label;
                                console.log(mode);
                                var IDE = ace.edit("IDE");
                                IDE.setTheme("ace/theme/vibrant_ink");
                                IDE.session.setMode("ace/mode/" + mode);
                                IDE.setOption("showPrintMargin", false);
                            });
                        });



                    </script>
                </div>
            </form>
        </ul>
      </div>
    </nav>

</footer>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  <script>
        function sleep(ms) {
          return new Promise(resolve => setTimeout(resolve, ms));
        }

        Terminal.loadAddon('fit');
        var term = new Terminal({cursorBlink: false, rows: 12});
        term.open(document.getElementById('terminal'));

        async function termclear() {
            term.destroy();
            await sleep(100);
            term = new Terminal({cursorBlink: false, rows: 12});
            term.open(document.getElementById('terminal'));
        };

        function termchange() {
                    var getmode = document.getElementById("mode");
                    var mode = getmode.options[getmode.selectedIndex].label;
                    var mode_code = getmode.options[getmode.selectedIndex].value;
                    var IDE = ace.edit("IDE");
                    var code = IDE.getValue();
                    var url = "http://" + location.host + "/function/" + mode_code;
                    console.log(url);
                    termclear()
                    $.ajax({
                        url: url,
                        type: 'post',
                        dataType: 'text',
                        headers: {'Content-Type': 'text/plain'},
                        // data: "print('hey')",
                        data: code,
                        success: function (data) {
                            console.log(data);
                            $(function () {
                                var writePrompt = function () {
                                    var termData = data.replace(/\r?\n/g, "\r\n");
                                    term.writeln(termData);
                                  };
                                writePrompt();
                                term.scrollToBottom();
                            });
                        },
                    });

                };


        $("pre").each(function() {
            $(this).click(function() {
                console.log($(this).text());
                document.execCommand("copy");
                var IDE = ace.edit("IDE");
                var code = $('<textarea />').html($(this).text()).text();
                IDE.setValue(code, -1);
            })
        });
    </script>



  </body>

</html>

================================================
FILE: templates/index.html
================================================
<html>

  <head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- UI based on the Play-With-Moby site and by the team at Play-With-Docker and the learning experiences they deliver everyday -->


<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/darkly/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic">
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.8/ace.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdn.rawgit.com/replit/jq-console/8baeef38/lib/jqconsole.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xterm/2.8.1/xterm.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/xterm/2.8.1/xterm.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xterm/2.8.1/addons/fit/fit.js"></script>

<style>
    html, body {
        height: 100%;
        background-color: #052f47;
        color: #fff
    }
    img {
        max-width: 100%
    }
    .mt50 {
        margin-top: 50px
    }
    .mt20 {
        margin-top: 20px
    }
    .mt10 {
        margin-top: 10px
    }
    .mb10 {
        margin-bottom: 10px
    }
    body {
        display: flex;
        flex-direction: column
    }
    body>* {
        flex: none
    }
    #IDE {
        background-color: #24323a
    }
    #terminal {
        height: 100%;
    }
    .navbar-header {
        margin-top: 5px
    }
    .navbar-header button {
        margin-left: 10px
    }
    .navbar-header input {
        color: #000;
        margin-left: 5px;
        width: 300px;
        display: none
    }
    .navbar {
        border-radius: 0px;
        margin-bottom: 0px
    }
    .navbar.navbar-inverse {
        background-color: #052f47;
        border-color: #052f47
    }
    .navbar.navbar-inverse a, .navbar.navbar-inverse .navbar-nav li a {
        color: #fff
    }
    .navbar.navbar-inverse a:hover, .navbar.navbar-inverse .navbar-nav li a:hover {
        text-decoration: underline
    }
    footer {
        background-color: #052f47
    }
    .navbar-brand {
        font-weight: 900;
        margin-left: 0px !important;
        vertical-align: middle;
        float: none
    }
    @media screen and (max-width: 600px) {
        .navbar-brand {
            font-size: 1.5em
        }
    }
    .panel {
        border: none;
        box-shadow: 0px 0px 1px #828282
    }
    .panel:hover {
        box-shadow: 0px 0px 6px #828282
    }
    .social {
        list-style: none;
        display: inline;
        margin-left: 10px;
        padding: 5px 8px
    }
    .social:hover {
        opacity: 0.7
    }
    .social img {
        width: 20px
    }
    .quora img {
        width: 17px
    }
    .facebook img {
        width: 16px
    }
    .panel-container {
        display: flex;
        flex-direction: row;
        overflow: hidden;
        height: 100%;
        flex: 1 1 auto;
        xtouch-action: none
    }
    .terminal {
        font-size: 15px
    }
    .panel-left, IDE {
        flex: 0 0 auto;
        width: 50%;
        min-width: 150px
    }
    .content {
        padding: 0 15px;
        overflow-y: auto
    }
    .content {
        padding: 0 15px
    }
    .splitter {
        flex: 0 0 auto;
        width: 18px;
        background: url(https://raw.githubusercontent.com/RickStrahl/jquery-resizable/master/assets/vsizegrip.png) center center no-repeat #101e26;
        min-height: 200px;
        cursor: col-resize
    }
    .panel-right {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        width: 100%;
        background-color: #000000
    }
    .panel-right>div {
        flex: 1 1 auto;
        margin-bottom: 15px;
        overflow-y: auto
    }
    .panel-right>div:last-of-type {
        margin-bottom: 0px
    }
    .panel-right>div.initialized {
        background-color: black
    }
    .post-tag {
        display: inline-block;
        background: rgba(42, 122, 226, 0.15);
        padding: 0 .5rem;
        margin-right: .5rem;
        border-radius: 4px;
        color: #2a7ae2;
        font-family: "Open Sans", serif;
        font-size: 90%
    }
    .post-tag:before {
        content: "\f02b";
        font-family: FontAwesome;
        padding-right: .5em
    }
    .post-tag:hover {
        text-decoration: none;
        background: #2a7ae2;
        color: #fff
    }
    small .post-tag {
        background: #eee;
        color: #000
    }
    small .post-tag:before {
        content: none
    }
    small .post-tag:hover {
        text-decoration: none;
        background: #000;
        color: #fff;
        cursor: default
    }
    .tags-expo :target:before {
        content: "";
        display: block;
        height: 72px;
        margin: -72px 0 0
    }
    @media (min-width: 38em) {
        .tags-expo .tags-expo-list {
            font-size: 2.9rem
        }
        .tags-expo .tags-expo-list .post-tag {
            margin: .2em .3em
        }
    }
    .tags-expo .tags-expo-section {
        font-family: "Open Sans", serif
    }
    .tags-expo .tags-expo-section ul {
        list-style-type: circle;
        list-style-position: inside;
        padding: 0
    }
    .tags-expo .tags-expo-section ul li {
        padding: 0 1rem
    }
    .tags-expo .tags-expo-section ul li:hover {
        list-style-type: disc
    }
    .tags-expo .tags-expo-section a {
        font-size: 20px
    }
    .tags-expo .tags-expo-section .post-date {
        display: inline-block;
        font-size: 80%;
        color: #000;
        margin: 0;
        padding: 0
    }
</style>

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
</head>
  <body>

    <header class="site-header">
<nav class="navbar navbar-default navbar-inverse">

    <div class="container">
      <div class="logo"><img src="../static/TIME2CODE-grey.png"></div>
        <div class="navbar-header">
        <!--<a class="navbar-brand" href="/">Time2Code</a>-->
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>

        </div>
  </div><!-- /.container-fluid -->
</nav>
</header>


    <div class="panel-container">
        <div class="panel-left" id="IDE"/>
    </div>

    <div class="splitter">
    </div>
    <div class="panel-right">
        <div id="terminal"></div>
          <script>

          </script>
    </div>
</div>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="https://rawgit.com/RickStrahl/jquery-resizable/master/dist/jquery-resizable.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.7/ace.js"></script>
<script>
    var IDE = ace.edit("IDE");

    IDE.setTheme("ace/theme/vibrant_ink");
    IDE.session.setMode("ace/mode/python");

    IDE.setShowPrintMargin(false);

    $(".panel-left").resizable({
        handleSelector: ".splitter",
        resizeHeight: false,
    });
</script>



  <footer>
    <nav class="navbar navbar-default">
      <div class="container-fluid">
        <ul class="nav navbar-nav">
            <li>
                <button id="code" onclick="termchange()" class="btn btn-success navbar-btn">RUN IT</button>
                <button id="code" onclick="termclear()" class="btn btn-danger navbar-btn">CLEAR TERM</button>
            </li>
            <form class="navbar-form navbar-right">
                <div class="form-group">
                  <select id="mode" class="form-control" style="float:right;">
                    <option label="python" value="python3">python3</option>
                    <option label="golang" value="golang">golang</option>
                    <option label="javascript" value="nodejs">nodejs</option>
                    <option label="fortran" value="fortran">fortran</option>
                    <option label="ruby" value="ruby">ruby</option>
                    <option label="powershell" value="powershell">powershell</option>
                    <option label="csharp" value="csharp-experimental">csharp-experimental</option>
                  </select>
                    <script>
                        document.getElementById("mode").value = "{{ code_lang }}";
                        var modeElement = document.getElementById("mode");
                        mode = modeElement.options[modeElement.selectedIndex].label;
                        var IDE = ace.edit("IDE");
                        var code = $('<textarea />').html(`{{ code_text }}`).text();
                        IDE.setValue(code, -1);
                        IDE.session.setMode("ace/mode/" + mode);
                        document.addEventListener("DOMContentLoaded", function(event){
                            $("#mode").change(function() {
                                var modeElement = document.getElementById("mode");
                                mode = modeElement.options[modeElement.selectedIndex].label;
                                console.log(mode);
                                var IDE = ace.edit("IDE");
                                IDE.setTheme("ace/theme/vibrant_ink");
                                IDE.session.setMode("ace/mode/" + mode);
                                IDE.setOption("showPrintMargin", false);
                            });
                        });
                    </script>
                </div>
            </form>
      </div>
    </nav>

</footer>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  <script>
        function sleep(ms) {
          return new Promise(resolve => setTimeout(resolve, ms));
        }

        var term = new Terminal({cursorBlink: false, rows: 40});
        term.open(document.getElementById('terminal'));

        function termchange() {
                    var getmode = document.getElementById("mode");
                    var mode = getmode.options[getmode.selectedIndex].label;
                    var mode_code = getmode.options[getmode.selectedIndex].value;
                    var IDE = ace.edit("IDE");
                    var code = IDE.getValue();
                    var url = "http://" + location.host + "/function/" + mode_code;
                    console.log(url)
                    $.ajax({
                        url: url,
                        type: 'post',
                        dataType: 'text',
                        headers: {'Content-Type': 'text/plain'},
                        // data: "print('hey')",
                        data: code,
                        success: function (data) {
                            console.log(data);
                            $(function () {
                                var writePrompt = function () {
                                    var termData = data.replace(/\r?\n/g, "\r\n");
                                    term.writeln(termData);
                                  };
                                writePrompt();
                                term.scrollToBottom();
                            });
                        },
                    });

                };

        async function termclear() {
            term.destroy();
            await sleep(100);
            term = new Terminal({cursorBlink: false, rows: 40});
            term.open(document.getElementById('terminal'));
        };
    </script>



  </body>

</html>

================================================
FILE: time2code-faas-cli-functions.yml
================================================
provider:
  name: faas
  gateway: http://localhost:31112

functions:
  time2code:
    fprocess: python3 handler.py
    image: jockdarock/time2code:master
  golang:
    fprocess: python3 time2go.py
    image: jockdarock/time2go:latest

  python3:
    fprocess: python3 time2py.py
    image: jockdarock/time2py:latest

  powershell:
    fprocess: python3 time2powershell.py
    image: jockdarock/time2powershell:latest

  nodejs:
    fprocess: python3 time2nodejs.py
    image: jockdarock/time2nodejs:latest

  csharp-experimental:
    fprocess: python3 time2CSharp.py
    image: jockdarock/time2csharp:latest

  fortran:
    fprocess: python3 time2fortran.py
    image: jockdarock/time2fortran:latest

  ruby:
    fprocess: python3 time2ruby.py
    image: jockdarock/time2ruby:latest


================================================
FILE: time2code-server-k8s.yml
================================================
apiVersion: v1
kind: Service
metadata:
  name: time2codeserver
spec:
  type: LoadBalancer
  ports:
  - name: time2codeserver-5555
    port: 5555
    protocol: TCP
    targetPort: 5555
  selector:
    app: time2codeserver
    component: time2codeserver

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: time2codeserver
spec:
  replicas: 3
  rollbackTo:
    revision: 0
  selector:
    matchLabels:
      app: time2codeserver
      component: time2codeserver
  strategy:
    rollingUpdate:
      maxSurge: 3
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: time2codeserver
        component: time2codeserver
    spec:
      containers:
      - image: jockdarock/time2codeserver:latest
        name: time2codeserver
        imagePullPolicy: Always
        env:
        - name: time2code_provider_url
          value: "http://time2codeserver.default:5555"
        ports:
        - containerPort: 5555
          protocol: TCP
      restartPolicy: Always


================================================
FILE: time2code-swarm-deploy.yml
================================================
version: "3"
services:
# Setup FaaS Framework First
# Core API services for FaaS are pinned, HA is provided for functions.
    gateway:
        volumes:
            - "/var/run/docker.sock:/var/run/docker.sock"
        ports:
            - 8080:8080
        image: functions/gateway:0.6.13
        networks:
            - functions
        environment:
            dnsrr: "true"  # Temporarily use dnsrr in place of VIP while issue persists on PWD
            read_timeout: "60"
            write_timeout: "60"
        deploy:
            placement:
                constraints: [node.role == manager]

    prometheus:
        image: functions/prometheus:latest  # autobuild from Dockerfile in repo.
        command: "-config.file=/etc/prometheus/prometheus.yml -storage.local.path=/prometheus -storage.local.memory-chunks=10000 --alertmanager.url=http://alertmanager:9093"
        ports:
            - 9090:9090
        depends_on:
            - gateway
            - alertmanager
        environment:
            no_proxy: "gateway"
        networks:
            - functions
        deploy:
            placement:
                constraints: [node.role == manager]

    alertmanager:
        image: functions/alertmanager:latest    # autobuild from Dockerfile in repo.
        environment:
            no_proxy: "gateway"
        command:
            - '-config.file=/alertmanager.yml'
        networks:
            - functions
        ports:
            - 9093:9093
        deploy:
            placement:
                constraints: [node.role == manager]

    # Code execution functions on FaaS
    # Python Code Execution
    python3:
        image: jockdarock/time2py:latest
        labels:
            function: "true"
        depends_on:
            - gateway
        networks:
            - functions
        environment:
            fprocess: "python3 time2py.py"
            no_proxy: "gateway"
            https_proxy: $https_proxy
            read_timeout: "60"
            write_timeout: "60"

    # Golang Code Execution
    golang:
        image: jockdarock/time2go:latest
        labels:
            function: "true"
        depends_on:
            - gateway
        networks:
            - functions
        environment:
            fprocess: "python3 time2go.py"
            no_proxy: "gateway"
            https_proxy: $https_proxy
            read_timeout: "60"
            write_timeout: "60"

    # Powershell Code Execution
    powershell:
        image: jockdarock/time2powershell:latest
        labels:
            function: "true"
        depends_on:
            - gateway
        networks:
            - functions
        environment:
            fprocess: "python3 time2powershell.py"
            no_proxy: "gateway"
            https_proxy: $https_proxy
            read_timeout: "60"
            write_timeout: "60"

    # DotNet / C# Code Execution
    csharp-experimental:
        image: jockdarock/time2csharp:latest
        labels:
            function: "true"
        depends_on:
            - gateway
        networks:
            - functions
        environment:
            fprocess: "python3 time2CSharp.py"
            no_proxy: "gateway"
            https_proxy: $https_proxy
            read_timeout: "60"
            write_timeout: "60"

    # NodeJS Code Execution
    nodejs:
        image: jockdarock/time2nodejs:latest
        labels:
            function: "true"
        depends_on:
            - gateway
        networks:
            - functions
        environment:
            fprocess: "python3 time2nodejs.py"
            no_proxy: "gateway"
            https_proxy: $https_proxy
            read_timeout: "60"
            write_timeout: "60"

    # Fortran Code Execution
    fortran:
        image: jockdarock/time2fortran:latest
        labels:
            function: "true"
        depends_on:
            - gateway
        networks:
            - functions
        environment:
            fprocess: "python3 time2fortran.py"
            no_proxy: "gateway"
            https_proxy: $https_proxy
            read_timeout: "60"
            write_timeout: "60"

    # Fortran Code Execution
    ruby:
        image: jockdarock/time2ruby:latest
        labels:
            function: "true"
        depends_on:
            - gateway
        networks:
            - functions
        environment:
            fprocess: "python3 time2ruby.py"
            no_proxy: "gateway"
            https_proxy: $https_proxy
            read_timeout: "60"
            write_timeout: "60"

    # Time2Code Code Editor / Flask Web Server
    time2codeserver:
      depends_on:
            - gateway
      build:
        context: .
        dockerfile: Dockerfile.nofaas
      deploy:
        replicas: 2
      image: jockdarock/time2codeserver:latest
      networks:
        - functions
      ports:
        - "5555:5555"

networks:
    functions:
        driver: overlay



================================================
FILE: time2deploy.sh
================================================
#!/bin/sh

echo "Deploying Time2Code on FaaS"
curl -O https://raw.githubusercontent.com/JockDaRock/Time2Code/master/time2code-swarm-deploy.yml
docker stack deploy time2code --compose-file time2code-swarm-deploy.yml
Download .txt
gitextract_8uxbsio_/

├── .gitignore
├── CONTRIBUTING.md
├── Dockerfile
├── Dockerfile.nofaas
├── FortranSample.md
├── LICENSE
├── QuickCodeTutorial.md
├── QuickCodeTutorial_PWK.md
├── README.md
├── Sample.md
├── code.txt
├── deploy_pwk.sh
├── docker-compose.yml
├── handler.py
├── ide-server.py
├── ide.py
├── ide_server.py
├── k8s_templates/
│   ├── aci-beta.yml
│   ├── faas_function_k8s.yml
│   └── str8_k8s.yml
├── minikube.sh
├── templates/
│   ├── alloy_server.html
│   ├── base_test.html
│   ├── base_test_server.html
│   ├── boostrap_server.html
│   ├── index-panel.html
│   ├── index-tut.html
│   ├── index-tutorial.html
│   └── index.html
├── time2code-faas-cli-functions.yml
├── time2code-server-k8s.yml
├── time2code-swarm-deploy.yml
└── time2deploy.sh
Download .txt
SYMBOL INDEX (15 symbols across 4 files)

FILE: handler.py
  class ProxyFix (line 16) | class ProxyFix(object):
    method __init__ (line 17) | def __init__(self, app):
    method __call__ (line 20) | def __call__(self, environ, start_response):
  class HeaderRewriterFix (line 32) | class HeaderRewriterFix(object):
    method __init__ (line 34) | def __init__(self, app, remove_headers=None, add_headers=None):
    method __call__ (line 39) | def __call__(self, environ, start_response):

FILE: ide-server.py
  function time2code (line 28) | def time2code():
  function code (line 51) | def code():
  function tutorial (line 72) | def tutorial():

FILE: ide.py
  function time2code (line 11) | def time2code():
  class ProxyFix (line 20) | class ProxyFix(object):
    method __init__ (line 21) | def __init__(self, app):
    method __call__ (line 24) | def __call__(self, environ, start_response):

FILE: ide_server.py
  function time2code (line 14) | def time2code():
  function tutorial (line 37) | def tutorial():
Condensed preview — 33 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (121K chars).
[
  {
    "path": ".gitignore",
    "chars": 187,
    "preview": "# Created by .ignore support plugin (hsz.mobi)\n### Example user template template\n### Example user template\n\n# IntelliJ "
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 3063,
    "preview": "## Contributing\n\n### Guidelines\n\nHere are a few guidelines for contributing:\n\n* If you have found a bug please raise an "
  },
  {
    "path": "Dockerfile",
    "chars": 771,
    "preview": "FROM alpine\n\nRUN apk add -Uuv --no-cache python3 \\\n    && apk upgrade -v --available --no-cache \\\n    && apk add ca-cert"
  },
  {
    "path": "Dockerfile.nofaas",
    "chars": 397,
    "preview": "FROM alpine\n\nRUN apk add -Uuv --no-cache python3 \\\n    && apk upgrade -v --available --no-cache \\\n    && apk add ca-cert"
  },
  {
    "path": "FortranSample.md",
    "chars": 321,
    "preview": "# Test out your code\n\n## Random instructions\n\nLike any programming language, we need to start with Hello World. Click th"
  },
  {
    "path": "LICENSE",
    "chars": 1077,
    "preview": "MIT License\n\nCopyright (c) 2017 Kristopher Jock Reed\n\nPermission is hereby granted, free of charge, to any person obtain"
  },
  {
    "path": "QuickCodeTutorial.md",
    "chars": 1642,
    "preview": "## Code Tutorial\n\nThis is a quick tutorial to highlight the tutorial page feature of Time2Code.  It is generated from Ma"
  },
  {
    "path": "QuickCodeTutorial_PWK.md",
    "chars": 2375,
    "preview": "## Code Tutorial\n\nThis is a quick tutorial to highlight the tutorial page feature of Time2Code.  It is generated from Ma"
  },
  {
    "path": "README.md",
    "chars": 4621,
    "preview": "# Time2Code\nA portable, scalable web based code editor to integrate into your code learning experiences.\n\nThe goal is to"
  },
  {
    "path": "Sample.md",
    "chars": 342,
    "preview": "# Test out your code\n\n## Random instructions\n\nStick this code in the right panel.\n\n```python\nimport requests\n\nurl = \"htt"
  },
  {
    "path": "code.txt",
    "chars": 326,
    "preview": "import requests\nimport json\n\nurl = \"https://sandboxapicem.cisco.com/api/v1/ticket\"\n\npayload = {\"username\": \"devnetuser\","
  },
  {
    "path": "deploy_pwk.sh",
    "chars": 577,
    "preview": "#!/bin/sh\n\nyum update -y && yum install -y git\n\nkubeadm init --apiserver-advertise-address $(hostname -i) && \\\nkubectl a"
  },
  {
    "path": "docker-compose.yml",
    "chars": 262,
    "preview": "version: \"3.0\"\nservices:\n  time2codeserver:\n    build:\n      context: .\n      dockerfile: Dockerfile.nofaas\n    image: j"
  },
  {
    "path": "handler.py",
    "chars": 1660,
    "preview": "#!/usr/bin/python\nfrom wsgiref.handlers import CGIHandler\nimport os\nfrom ide_server import app\n\nquery_params = os.getenv"
  },
  {
    "path": "ide-server.py",
    "chars": 2892,
    "preview": "from flask import Flask, request, render_template, Markup\nimport requests\nfrom urllib.parse import urlparse\nimport markd"
  },
  {
    "path": "ide.py",
    "chars": 1015,
    "preview": "from flask import Flask, request, render_template, Markup\nimport requests\nfrom urllib.parse import urlparse\nimport markd"
  },
  {
    "path": "ide_server.py",
    "chars": 1797,
    "preview": "from flask import Flask, request, render_template, Markup\nimport requests\nfrom urllib.parse import urlparse\nimport markd"
  },
  {
    "path": "k8s_templates/aci-beta.yml",
    "chars": 8347,
    "preview": "apiVersion: v1\nkind: Service\nmetadata:\n  name: time2codeserver\nspec:\n  type: LoadBalancer\n  ports:\n  - name: time2codese"
  },
  {
    "path": "k8s_templates/faas_function_k8s.yml",
    "chars": 4443,
    "preview": "apiVersion: extensions/v1beta1\nkind: Deployment\nmetadata:\n  name: csharp-experimental\nspec:\n  replicas: 0\n  rollbackTo:\n"
  },
  {
    "path": "k8s_templates/str8_k8s.yml",
    "chars": 3993,
    "preview": "apiVersion: v1\nkind: Service\nmetadata:\n  name: time2codeserver\nspec:\n  type: LoadBalancer\n  ports:\n  - name: time2codese"
  },
  {
    "path": "minikube.sh",
    "chars": 453,
    "preview": "#! /bin/bash\n\ngit clone https://github.com/alexellis/faas-netes\n\ncurl -sSL cli.get-faas.com | sudo sh\n\nkubectl apply -f "
  },
  {
    "path": "templates/alloy_server.html",
    "chars": 2223,
    "preview": "<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <title>Base Test Une</title>\n    <script src=\"http://cdn.alloyui."
  },
  {
    "path": "templates/base_test.html",
    "chars": 3990,
    "preview": "<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <title>Base Test Une</title>\n    <script src=\"https://cdn.rawgit."
  },
  {
    "path": "templates/base_test_server.html",
    "chars": 3979,
    "preview": "<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <title>Base Test Une</title>\n    <script src=\"https://cdn.rawgit."
  },
  {
    "path": "templates/boostrap_server.html",
    "chars": 7417,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <title>Bootstrap Example</title>\n  <meta charset=\"utf-8\">\n  <meta name=\"viewpo"
  },
  {
    "path": "templates/index-panel.html",
    "chars": 12235,
    "preview": "<html>\n\n  <head>\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n<meta name=\"viewport\" content=\"width=device-width"
  },
  {
    "path": "templates/index-tut.html",
    "chars": 11994,
    "preview": "<html>\n\n  <head>\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n<meta name=\"viewport\" content=\"width=device-width"
  },
  {
    "path": "templates/index-tutorial.html",
    "chars": 11993,
    "preview": "<html>\n\n  <head>\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n<meta name=\"viewport\" content=\"width=device-width"
  },
  {
    "path": "templates/index.html",
    "chars": 12234,
    "preview": "<html>\n\n  <head>\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n<meta name=\"viewport\" content=\"width=device-width"
  },
  {
    "path": "time2code-faas-cli-functions.yml",
    "chars": 783,
    "preview": "provider:\n  name: faas\n  gateway: http://localhost:31112\n\nfunctions:\n  time2code:\n    fprocess: python3 handler.py\n    i"
  },
  {
    "path": "time2code-server-k8s.yml",
    "chars": 1022,
    "preview": "apiVersion: v1\nkind: Service\nmetadata:\n  name: time2codeserver\nspec:\n  type: LoadBalancer\n  ports:\n  - name: time2codese"
  },
  {
    "path": "time2code-swarm-deploy.yml",
    "chars": 4912,
    "preview": "version: \"3\"\nservices:\n# Setup FaaS Framework First\n# Core API services for FaaS are pinned, HA is provided for function"
  },
  {
    "path": "time2deploy.sh",
    "chars": 214,
    "preview": "#!/bin/sh\n\necho \"Deploying Time2Code on FaaS\"\ncurl -O https://raw.githubusercontent.com/JockDaRock/Time2Code/master/time"
  }
]

About this extraction

This page contains the full source code of the JockDaRock/Time2Code GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 33 files (110.9 KB), approximately 27.7k tokens, and a symbol index with 15 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!