├── images
├── PWD-5555.png
├── code_gif.gif
├── lang_sel.png
└── python_sample0.png
├── static
└── TIME2CODE-grey.png
├── .gitignore
├── time2deploy.sh
├── docker-compose.yml
├── code.txt
├── FortranSample.md
├── Sample.md
├── Dockerfile.nofaas
├── minikube.sh
├── deploy_pwk.sh
├── Dockerfile
├── time2code-faas-cli-functions.yml
├── LICENSE
├── ide.py
├── time2code-server-k8s.yml
├── handler.py
├── QuickCodeTutorial.md
├── ide_server.py
├── templates
├── alloy_server.html
├── base_test_server.html
├── base_test.html
├── boostrap_server.html
├── index-tut.html
├── index-tutorial.html
├── index.html
└── index-panel.html
├── QuickCodeTutorial_PWK.md
├── CONTRIBUTING.md
├── ide-server.py
├── README.md
├── k8s_templates
├── str8_k8s.yml
├── faas_function_k8s.yml
└── aci-beta.yml
└── time2code-swarm-deploy.yml
/images/PWD-5555.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JockDaRock/Time2Code/HEAD/images/PWD-5555.png
--------------------------------------------------------------------------------
/images/code_gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JockDaRock/Time2Code/HEAD/images/code_gif.gif
--------------------------------------------------------------------------------
/images/lang_sel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JockDaRock/Time2Code/HEAD/images/lang_sel.png
--------------------------------------------------------------------------------
/images/python_sample0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JockDaRock/Time2Code/HEAD/images/python_sample0.png
--------------------------------------------------------------------------------
/static/TIME2CODE-grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JockDaRock/Time2Code/HEAD/static/TIME2CODE-grey.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### Example user template template
3 | ### Example user template
4 |
5 | # IntelliJ project files
6 | .idea
7 | *.iml
8 | out
9 | gen
10 | .time2code-faas-cli-minikube.yml
11 |
--------------------------------------------------------------------------------
/time2deploy.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | echo "Deploying Time2Code on FaaS"
4 | curl -O https://raw.githubusercontent.com/JockDaRock/Time2Code/master/time2code-swarm-deploy.yml
5 | docker stack deploy time2code --compose-file time2code-swarm-deploy.yml
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3.0"
2 | services:
3 | time2codeserver:
4 | build:
5 | context: .
6 | dockerfile: Dockerfile.nofaas
7 | image: jockdarock/time2codeserver:latest
8 | networks:
9 | - time2net
10 | ports:
11 | - "5555:5555"
12 | networks:
13 | time2net:
14 | driver: overlay
--------------------------------------------------------------------------------
/code.txt:
--------------------------------------------------------------------------------
1 | import requests
2 | import json
3 |
4 | url = "https://sandboxapicem.cisco.com/api/v1/ticket"
5 |
6 | payload = {"username": "devnetuser", "password": "Cisco123!"}
7 | data = json.dumps(payload)
8 | print(data)
9 | headers = {"content-type": "application/json"}
10 |
11 | response = requests.post(url, data=data, headers=headers, verify=False)
12 |
13 | print(response.text)
--------------------------------------------------------------------------------
/FortranSample.md:
--------------------------------------------------------------------------------
1 | # Test out your code
2 |
3 | ## Random instructions
4 |
5 | Like any programming language, we need to start with Hello World. Click the code
6 |
7 | ```fortran
8 | program hello
9 | Print *, "Hello World!"
10 | end program Hello
11 | ```
12 |
13 | Then click the `RUN IT` button at the bottom navigation bar.
14 |
15 | Wait a sec...
16 |
17 | dot dot dot
18 |
19 | and your code is complete.
20 |
21 |
--------------------------------------------------------------------------------
/Sample.md:
--------------------------------------------------------------------------------
1 | # Test out your code
2 |
3 | ## Random instructions
4 |
5 | Stick this code in the right panel.
6 |
7 | ```python
8 | import requests
9 |
10 | url = "https://httpbin.org/get"
11 |
12 | r = requests.get(url)
13 |
14 | print(r.status_code)
15 | print(r.headers)
16 | print(r.text)
17 | ```
18 |
19 | Then click the `RUN IT` button at the bottom navigation bar.
20 |
21 | Wait a sec...
22 |
23 | dot dot dot
24 |
25 | and the your code complete.
26 |
27 |
--------------------------------------------------------------------------------
/Dockerfile.nofaas:
--------------------------------------------------------------------------------
1 | FROM alpine
2 |
3 | RUN apk add -Uuv --no-cache python3 \
4 | && apk upgrade -v --available --no-cache \
5 | && apk add ca-certificates && pip3 install --no-cache-dir --upgrade pip setuptools wheel \
6 | && pip3 install requests flask markdown pymdown.extensions Pygments
7 |
8 | WORKDIR /root/
9 |
10 | COPY static ./static
11 | COPY ide-server.py .
12 | COPY templates ./templates
13 |
14 | EXPOSE 5555
15 |
16 | CMD ["python3", "ide-server.py"]
--------------------------------------------------------------------------------
/minikube.sh:
--------------------------------------------------------------------------------
1 | #! /bin/bash
2 |
3 | git clone https://github.com/alexellis/faas-netes
4 |
5 | curl -sSL cli.get-faas.com | sudo sh
6 |
7 | kubectl apply -f faas-netes/faas.yml,faas-netes/monitoring.yml,./time2code-server-k8s.yml
8 |
9 | sed "s/localhost:31112/$(minikube ip):31112/" time2code-faas-cli-functions.yml > .time2code-faas-cli-minikube.yml
10 |
11 | echo "Load the Code execution Functions with the faas-cli and then navigate to this site http://$(minikube ip):31114 in your favorite browser."
12 |
--------------------------------------------------------------------------------
/deploy_pwk.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | yum update -y && yum install -y git
4 |
5 | kubeadm init --apiserver-advertise-address $(hostname -i) && \
6 | kubectl apply -n kube-system -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
7 |
8 | cd /root/
9 | git clone https://github.com/alexellis/faas-netes.git \
10 | && cd faas-netes && kubectl apply -f faas.yml,rbac.yml,monitoring.yml
11 |
12 | cd /root/
13 | curl -sSL cli.get-faas.com | sh
14 | git clone https://github.com/JockDaRock/Time2Code.git \
15 | && cd Time2Code && git checkout dev
16 | faas-cli -action deploy -f ~/Time2Code/time2code-faas-cli-functions.yml
17 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM alpine
2 |
3 | RUN apk add -Uuv --no-cache python3 \
4 | && apk upgrade -v --available --no-cache \
5 | && apk add ca-certificates && pip3 install --no-cache-dir --upgrade pip setuptools wheel \
6 | && pip3 install requests flask markdown
7 |
8 | # ADD https://github.com/alexellis/faas/releases/download/0.6.15/fwatchdog /usr/bin
9 | ADD https://github.com/openfaas-incubator/of-watchdog/releases/download/0.2.1/of-watchdog /usr/bin/fwatchdog
10 |
11 |
12 | RUN chmod +x /usr/bin/fwatchdog
13 |
14 | WORKDIR /root/
15 |
16 | # COPY ide.py .
17 | COPY ide_server.py .
18 | COPY handler.py .
19 | COPY templates ./templates
20 |
21 | ENV fprocess="python3 handler.py"
22 | ENV cgi_headers="true"
23 | ENV cgi_body="true"
24 | ENV mode="serializing"
25 | ENV content_type="text/html"
26 |
27 | HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1
28 |
29 | CMD ["fwatchdog"]
--------------------------------------------------------------------------------
/time2code-faas-cli-functions.yml:
--------------------------------------------------------------------------------
1 | provider:
2 | name: faas
3 | gateway: http://localhost:31112
4 |
5 | functions:
6 | time2code:
7 | fprocess: python3 handler.py
8 | image: jockdarock/time2code:master
9 | golang:
10 | fprocess: python3 time2go.py
11 | image: jockdarock/time2go:latest
12 |
13 | python3:
14 | fprocess: python3 time2py.py
15 | image: jockdarock/time2py:latest
16 |
17 | powershell:
18 | fprocess: python3 time2powershell.py
19 | image: jockdarock/time2powershell:latest
20 |
21 | nodejs:
22 | fprocess: python3 time2nodejs.py
23 | image: jockdarock/time2nodejs:latest
24 |
25 | csharp-experimental:
26 | fprocess: python3 time2CSharp.py
27 | image: jockdarock/time2csharp:latest
28 |
29 | fortran:
30 | fprocess: python3 time2fortran.py
31 | image: jockdarock/time2fortran:latest
32 |
33 | ruby:
34 | fprocess: python3 time2ruby.py
35 | image: jockdarock/time2ruby:latest
36 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Kristopher Jock Reed
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/ide.py:
--------------------------------------------------------------------------------
1 | from flask import Flask, request, render_template, Markup
2 | import requests
3 | from urllib.parse import urlparse
4 | import markdown
5 | from wsgiref.handlers import CGIHandler
6 |
7 | app = Flask(__name__)
8 |
9 |
10 | @app.route('/')
11 | def time2code():
12 | url = "https://raw.githubusercontent.com/JockDaRock/Time2Code/master/Sample.md"
13 | r = requests.get(url)
14 | mark = r.text
15 |
16 | content = Markup(markdown.markdown(mark))
17 | return render_template('index-panel.html', markd=content)
18 |
19 |
20 | class ProxyFix(object):
21 | def __init__(self, app):
22 | self.app = app
23 |
24 | def __call__(self, environ, start_response):
25 | environ['SERVER_NAME'] = "localhost"
26 | environ['SERVER_PORT'] = "8080"
27 | environ['REQUEST_METHOD'] = "GET"
28 | environ['SCRIPT_NAME'] = ""
29 | environ['PATH_INFO'] = "/"
30 | environ['QUERY_STRING'] = ""
31 | environ['SERVER_PROTOCOL'] = "HTTP/1.1"
32 | return self.app(environ, start_response)
33 |
34 | if __name__ == '__main__':
35 | app.wsgi_app = ProxyFix(app.wsgi_app)
36 | CGIHandler().run(app)
37 |
--------------------------------------------------------------------------------
/time2code-server-k8s.yml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | name: time2codeserver
5 | spec:
6 | type: LoadBalancer
7 | ports:
8 | - name: time2codeserver-5555
9 | port: 5555
10 | protocol: TCP
11 | targetPort: 5555
12 | selector:
13 | app: time2codeserver
14 | component: time2codeserver
15 |
16 | ---
17 | apiVersion: extensions/v1beta1
18 | kind: Deployment
19 | metadata:
20 | name: time2codeserver
21 | spec:
22 | replicas: 3
23 | rollbackTo:
24 | revision: 0
25 | selector:
26 | matchLabels:
27 | app: time2codeserver
28 | component: time2codeserver
29 | strategy:
30 | rollingUpdate:
31 | maxSurge: 3
32 | maxUnavailable: 1
33 | type: RollingUpdate
34 | template:
35 | metadata:
36 | labels:
37 | app: time2codeserver
38 | component: time2codeserver
39 | spec:
40 | containers:
41 | - image: jockdarock/time2codeserver:latest
42 | name: time2codeserver
43 | imagePullPolicy: Always
44 | env:
45 | - name: time2code_provider_url
46 | value: "http://time2codeserver.default:5555"
47 | ports:
48 | - containerPort: 5555
49 | protocol: TCP
50 | restartPolicy: Always
51 |
--------------------------------------------------------------------------------
/handler.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | from wsgiref.handlers import CGIHandler
3 | import os
4 | from ide_server import app
5 |
6 | query_params = os.getenv("Http_Query", default="")
7 | whole_path = os.getenv("Http_Path", default="/ip")
8 | split_path = whole_path.split('/')
9 | if len(split_path) > 3:
10 | route_path = '/' + '/'.join(split_path[3:])
11 | else:
12 | route_path = "/"
13 | http_method = os.getenv("Http_Method", default="GET")
14 |
15 |
16 | class ProxyFix(object):
17 | def __init__(self, app):
18 | self.app = app
19 |
20 | def __call__(self, environ, start_response):
21 | environ['SERVER_NAME'] = "127.0.0.1"
22 | environ['SERVER_PORT'] = "8080"
23 | environ['REQUEST_METHOD'] = http_method
24 | environ['SCRIPT_NAME'] = ""
25 | environ['PATH_INFO'] = route_path
26 | environ['QUERY_STRING'] = query_params
27 | environ['SERVER_PROTOCOL'] = "HTTP/1.1"
28 | environ['Http_X_Forwarded_For'] = os.getenv("Http_X_Forwarded_For", "127.0.0.1")
29 | return self.app(environ, start_response)
30 |
31 |
32 | class HeaderRewriterFix(object):
33 |
34 | def __init__(self, app, remove_headers=None, add_headers=None):
35 | self.app = app
36 | self.remove_headers = set(x.lower() for x in (remove_headers or ()))
37 | self.add_headers = list(add_headers or ())
38 |
39 | def __call__(self, environ, start_response):
40 | def rewriting_start_response(status, headers, exc_info=None):
41 | new_headers = []
42 | return start_response(status, new_headers, exc_info)
43 | return self.app(environ, rewriting_start_response)
44 |
45 | if __name__ == '__main__':
46 | app.wsgi_app = ProxyFix(app.wsgi_app)
47 | app.wsgi_app = HeaderRewriterFix(app.wsgi_app, remove_headers=['Status'])
48 | CGIHandler().run(app)
49 |
--------------------------------------------------------------------------------
/QuickCodeTutorial.md:
--------------------------------------------------------------------------------
1 | ## Code Tutorial
2 |
3 | This is a quick tutorial to highlight the tutorial page feature of Time2Code. It is generated from MarkDown pages on GitHub.
4 |
5 | I will do a few quick HTTP Request code examples you can try in a few languages.
6 |
7 | ### Golang
8 |
9 | Select the Golang code language from the menu button on the bottom navbar.
10 |
11 | 
12 |
13 | Then enter the Code below in the **IDE** on the **right**.
14 |
15 | ```golang
16 | package main
17 |
18 | import (
19 | "fmt"
20 | "net/http"
21 | "io/ioutil"
22 | )
23 |
24 | func main() {
25 |
26 | url := "http://api.open-notify.org/iss-now.json"
27 |
28 | req, _ := http.NewRequest("GET", url, nil)
29 |
30 | req.Header.Add("cache-control", "no-cache")
31 |
32 | res, _ := http.DefaultClient.Do(req)
33 |
34 | defer res.Body.Close()
35 | body, _ := ioutil.ReadAll(res.Body)
36 |
37 | fmt.Println(res)
38 | fmt.Println(string(body))
39 |
40 | }
41 | ```
42 | Click the **RUN IT** button and watch as your code is executed quickly.
43 |
44 | Click the **CLEAR TERM** button once you are done and Repeat the same steps as above for the NodeJS and Python examples.
45 |
46 | **AND Dont forget to select the appropriate code langauge when running the different code snippets.**
47 |
48 | ### NodeJS
49 |
50 | ```node
51 | var request = require("request");
52 |
53 | var options = { method: 'GET',
54 | url: 'http://api.open-notify.org/iss-now.json',
55 | headers: { 'cache-control': 'no-cache' } };
56 |
57 | request(options, function (error, response, body) {
58 | if (error) throw new Error(error);
59 |
60 | console.log(body);
61 | });
62 | ```
63 |
64 | ### Python
65 |
66 |
67 | ```python
68 | import requests
69 |
70 | url = "http://api.open-notify.org/iss-now.json"
71 |
72 | r = requests.get(url)
73 |
74 | print(r.text)
75 | ```
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/ide_server.py:
--------------------------------------------------------------------------------
1 | from flask import Flask, request, render_template, Markup
2 | import requests
3 | from urllib.parse import urlparse
4 | import markdown
5 | import os
6 | import subprocess
7 | import socket
8 |
9 |
10 | app = Flask(__name__)
11 |
12 |
13 | @app.route('/')
14 | def time2code():
15 | text = request.args.get('code')
16 | lang = request.args.get('lang')
17 | straight_text = request.args.get('straight_text')
18 | code_text = ""
19 |
20 | if text:
21 | r_text = requests.get(text + "?raw=true")
22 | code_text = r_text.text
23 | elif straight_text:
24 | code_text = straight_text
25 | else:
26 | code_text = ""
27 |
28 | if lang:
29 | code_lang = lang
30 | else:
31 | code_lang = "python3"
32 |
33 | return render_template('index.html', code_text=code_text, code_lang=code_lang)
34 |
35 |
36 | @app.route('/tutorial')
37 | def tutorial():
38 | text = request.args.get('code')
39 | lang = request.args.get('lang')
40 | straight_text = request.args.get('straight_text')
41 | get_tut = request.args.get('tut')
42 | code_text = ""
43 | tut_url = ""
44 | mark = ""
45 |
46 | if get_tut:
47 | tut_url = get_tut + "?raw=true"
48 | r_tut = requests.get(tut_url)
49 | mark = r_tut.text
50 | else:
51 | tut_url = "https://raw.githubusercontent.com/JockDaRock/Time2Code/master/Sample.md?raw=true"
52 | r_tut = requests.get(tut_url)
53 | mark = r_tut.text
54 |
55 | if text:
56 | r_text = requests.get(text + "?raw=true")
57 | code_text = r_text.text
58 | elif straight_text:
59 | code_text = straight_text
60 |
61 | if lang:
62 | code_lang = lang
63 | else:
64 | code_lang = "python3"
65 |
66 | content = Markup(markdown.markdown(mark, extensions=['pymdownx.github', 'pymdownx.highlight']))
67 | return render_template('index-tutorial.html', markdown=content, code_text=code_text, code_lang=code_lang)
68 |
69 |
70 | if __name__ == '__main__':
71 | app.run(host="0.0.0.0", port=5555, debug=True)
72 |
73 |
--------------------------------------------------------------------------------
/templates/alloy_server.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Base Test Une
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
24 |
25 |
26 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/QuickCodeTutorial_PWK.md:
--------------------------------------------------------------------------------
1 | ## Code Tutorial
2 |
3 | This is a quick tutorial to highlight the tutorial page feature of Time2Code. It is generated from MarkDown pages on GitHub.
4 |
5 | I will do a few quick HTTP Request code examples you can try in a few languages.
6 |
7 | If you are viewing this on GitHub you will need to get Time2Code started before you can do anything else.
8 |
9 | First click the **Try in PWD** Button.
10 |
11 | [](http://play-with-docker.com?stack=https://raw.githubusercontent.com/JockDaRock/Time2Code/master/time2code-swarm-deploy.yml&stack_name=time2code)
12 |
13 | Once Time2Code is started up click the 5555 tab at the top of the Play-With-Docker site.
14 |
15 | 
16 |
17 | Add `/tutorial?tut=https://github.com/JockDaRock/Time2Code/blob/master/QuickCodeTutorial.md` to the URL in the browser.
18 |
19 | Continue with the instructions below...
20 |
21 | ### Golang
22 |
23 | Select the Golang code language from the menu button on the bottom navbar.
24 |
25 | 
26 |
27 | Then enter the Code below in the **IDE** on the **right**.
28 |
29 | ```Golang
30 | package main
31 |
32 | import (
33 | "fmt"
34 | "net/http"
35 | "io/ioutil"
36 | )
37 |
38 | func main() {
39 |
40 | url := "http://api.open-notify.org/iss-now.json"
41 |
42 | req, _ := http.NewRequest("GET", url, nil)
43 |
44 | req.Header.Add("cache-control", "no-cache")
45 |
46 | res, _ := http.DefaultClient.Do(req)
47 |
48 | defer res.Body.Close()
49 | body, _ := ioutil.ReadAll(res.Body)
50 |
51 | fmt.Println(res)
52 | fmt.Println(string(body))
53 |
54 | }
55 | ```
56 | Click the **RUN IT** button and watch as your code is executed quickly.
57 |
58 | Click the **CLEAR TERM** button once you are done and Repeat the same steps as above for the NodeJS and Python examples.
59 |
60 | **AND Dont forget to select the appropriate code language when running the different code snippets.**
61 |
62 | ### NodeJS
63 |
64 | ```NodeJS
65 | var request = require("request");
66 |
67 | var options = { method: 'GET',
68 | url: 'http://api.open-notify.org/iss-now.json',
69 | headers: { 'cache-control': 'no-cache' } };
70 |
71 | request(options, function (error, response, body) {
72 | if (error) throw new Error(error);
73 |
74 | console.log(body);
75 | });
76 | ```
77 |
78 | ### Python
79 |
80 |
81 | ```Python
82 | import requests
83 |
84 | url = "http://api.open-notify.org/iss-now.json"
85 |
86 | r = requests.get(url)
87 |
88 | print(r.text)
89 | ```
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## Contributing
2 |
3 | ### Guidelines
4 |
5 | Here are a few guidelines for contributing:
6 |
7 | * If you have found a bug please raise an issue and fill out the whole template.
8 | * Don't raise PRs for typos, these aren't necessary - just raise an Issue
9 | * If you would like to contribute to the codebase please raise an issue to propose the change and fill out the whole template.
10 | * If the documentation can be improved / translated etc please raise an issue to discuss.
11 |
12 | * Please always provide a summary of what you changed, how you did it and how it can be tested.
13 |
14 | ### Community
15 |
16 | 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.
17 |
18 | ### License
19 |
20 | This project is licensed under the MIT License.
21 |
22 | #### Sign your work
23 |
24 | The sign-off is a simple line at the end of the explanation for a patch. Your
25 | signature certifies that you wrote the patch or otherwise have the right to pass
26 | it on as an open-source patch. The rules are pretty simple: if you can certify
27 | the below (from [developercertificate.org](http://developercertificate.org/)):
28 |
29 | ```
30 | Developer Certificate of Origin
31 | Version 1.1
32 |
33 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
34 | 1 Letterman Drive
35 | Suite D4700
36 | San Francisco, CA, 94129
37 |
38 | Everyone is permitted to copy and distribute verbatim copies of this
39 | license document, but changing it is not allowed.
40 |
41 | Developer's Certificate of Origin 1.1
42 |
43 | By making a contribution to this project, I certify that:
44 |
45 | (a) The contribution was created in whole or in part by me and I
46 | have the right to submit it under the open source license
47 | indicated in the file; or
48 |
49 | (b) The contribution is based upon previous work that, to the best
50 | of my knowledge, is covered under an appropriate open source
51 | license and I have the right under that license to submit that
52 | work with modifications, whether created in whole or in part
53 | by me, under the same open source license (unless I am
54 | permitted to submit under a different license), as indicated
55 | in the file; or
56 |
57 | (c) The contribution was provided directly to me by some other
58 | person who certified (a), (b) or (c) and I have not modified
59 | it.
60 |
61 | (d) I understand and agree that this project and the contribution
62 | are public and that a record of the contribution (including all
63 | personal information I submit with it, including my sign-off) is
64 | maintained indefinitely and may be redistributed consistent with
65 | this project or the open source license(s) involved.
66 | ```
67 |
68 | Then you just add a line to every git commit message:
69 |
70 | Signed-off-by: Joe Smith
71 |
72 | Use your real name (sorry, no pseudonyms or anonymous contributions.)
73 |
74 | If you set your `user.name` and `user.email` git configs, you can sign your
75 | commit automatically with `git commit -s`.
76 |
77 | * Please sign your commits with `git commit -s` so that commits are traceable.
--------------------------------------------------------------------------------
/ide-server.py:
--------------------------------------------------------------------------------
1 | from flask import Flask, request, render_template, Markup
2 | import requests
3 | from urllib.parse import urlparse
4 | import markdown
5 | import os
6 | import subprocess
7 | import socket
8 |
9 |
10 | app = Flask(__name__)
11 |
12 | try:
13 | # Looking for the IP address on the K8s
14 | faas = "faas-netesd.default"
15 | ip = socket.getaddrinfo(faas, 0, 0, 0, 0)
16 | faas_port = 8080
17 | swarm_tag = ""
18 | except Exception:
19 | # finds Docker swarm host IP upon no K8s
20 | p1 = subprocess.Popen(["/sbin/ip", "route"], stdout=subprocess.PIPE)
21 | p2 = subprocess.Popen(["awk", "/default/ { print $3 }"], stdin=p1.stdout, stdout=subprocess.PIPE)
22 | faas = (p2.stdout).read().decode("utf-8").replace("\n", "")
23 | faas_port = 8080
24 | swarm_tag = "time2code_"
25 |
26 |
27 | @app.route('/')
28 | def time2code():
29 | text = request.args.get('code')
30 | lang = request.args.get('lang')
31 | straight_text = request.args.get('straight_text')
32 | code_text = ""
33 |
34 | if text:
35 | r_text = requests.get(text + "?raw=true")
36 | code_text = r_text.text
37 | elif straight_text:
38 | code_text = straight_text
39 | else:
40 | code_text = ""
41 |
42 | if lang:
43 | code_lang = lang
44 | else:
45 | code_lang = "python3"
46 |
47 | return render_template('index-panel.html', code_text=code_text, code_lang=code_lang)
48 |
49 |
50 | @app.route('/code', methods=['POST'])
51 | def code():
52 | if request.method == 'POST':
53 | data = request.data
54 | lang = request.args.get('lang')
55 | hosturl = urlparse(request.url)
56 | host = hosturl.hostname
57 | # url = "http://%s:%s/function/time2py" % host
58 | url = "http://%s:%s/function/%s%s" % (faas, faas_port, swarm_tag, lang)
59 | # print(url)
60 | headers = {"Content-Type": "text/plain"}
61 |
62 | code_exec = requests.post(url, data=data, headers=headers)
63 |
64 | resp = code_exec.text
65 |
66 | # print(resp)
67 |
68 | return resp
69 |
70 |
71 | @app.route('/tutorial')
72 | def tutorial():
73 | text = request.args.get('code')
74 | lang = request.args.get('lang')
75 | straight_text = request.args.get('straight_text')
76 | get_tut = request.args.get('tut')
77 | code_text = ""
78 | tut_url = ""
79 | mark = ""
80 |
81 | if get_tut:
82 | tut_url = get_tut + "?raw=true"
83 | r_tut = requests.get(tut_url)
84 | mark = r_tut.text
85 | else:
86 | tut_url = "https://raw.githubusercontent.com/JockDaRock/Time2Code/master/Sample.md?raw=true"
87 | r_tut = requests.get(tut_url)
88 | mark = r_tut.text
89 |
90 | if text:
91 | r_text = requests.get(text + "?raw=true")
92 | code_text = r_text.text
93 | elif straight_text:
94 | code_text = straight_text
95 |
96 | if lang:
97 | code_lang = lang
98 | else:
99 | code_lang = "python3"
100 |
101 | content = Markup(markdown.markdown(mark, extensions=['pymdownx.github', 'pymdownx.highlight']))
102 | return render_template('index-tut.html', markdown=content, code_text=code_text, code_lang=code_lang)
103 |
104 |
105 | if __name__ == '__main__':
106 | app.run(host="0.0.0.0", port=5555, debug=True)
107 |
108 |
--------------------------------------------------------------------------------
/templates/base_test_server.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Base Test Une
5 |
6 |
7 |
8 |
9 |
25 |