repl.it
@pieromqwerty/

demo-api

Python

No description

fork
loading
Files
  • main.py
  • templates
  • guru99.txt
  • tree1.txt
  • tree2.txt
  • Packager files
  • poetry.lock
  • pyproject.toml
  • requirements.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from flask import Flask, render_template, redirect, render_template_string
from flask_restful import Api, Resource, reqparse
import random
import json
from numpy import *
from threading import Thread

#setting up flask
app = Flask(__name__)
api = Api(app)

head = '<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width, initial-scale=1"><style>ul, #myUL{list-style-type: none;}#myUL {margin: 0;padding: 0;}.caret {cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}.caret::before {content: "\25B6";color: black;display: inline-block;margin-right: 6px;}.caret-down::before {-ms-transform: rotate(90deg);-webkit-transform: rotate(90deg);transform: rotate(90deg);}.nested {display: none;}.active{display: block;}</style></head><body>'

class dataReturn(Resource):
	def get(self, id):
		data = id
		data = '<!DOCTYPE html><html><body><a href="https://demo.api.piemadd.com/file/1" class="button">File 1</a><a href="https://demo.api.piemadd.com/file/2" class="button">File 2</a><p>'+data+'<p></body></html>'
		data = data.replace('					', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
		data = data.replace('				', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
		data = data.replace('			', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
		data = data.replace('		', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
		data = data.replace('	', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
		data = data.replace('''
''', '<br>')
		data = data.replace('<br><br>', '<br>')
		f = open("templates/rendered.html","w+")
		f.write(data)
		#return render_template('rendered.html')
		return data

class fileReturn(Resource):
	def get(self, id):
		data = id
		f=open("tree"+data+".txt", "r")
		data = f.read()
		data = '<!DOCTYPE html><html><body><a href="https://demo.api.piemadd.com/file/1" class="button">File 1</a><a href="https://demo.api.piemadd.com/file/2" class="button">File 2</a><p>'+data+'<p></body></html>'
		data = data.replace('					', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
		data = data.replace('				', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
		data = data.replace('			', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
		data = data.replace('		', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
		data = data.replace('	', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
		data = data.replace('''
''', '<br>')
		data = data.replace('<br><br>', '<br>')
		f = open("templates/rendered.html","w+")
		f.write(data)
		#return data
		return render_template('file'+data+'.txt')

#routing to index page
@app.route('/')
def index():
    return render_template('index.html')

#----------

#adding galaxy api resources
api.add_resource(dataReturn, "/data/<string:id>")
api.add_resource(fileReturn, "/file/<string:id>")

#----------

#running webserver
def run():
  app.run(host='0.0.0.0',port=8080)

def keep_alive():  
    t = Thread(target=run)
    t.start()

def yeet(data):
	data = '<!DOCTYPE html><html><body><a href="https://demo.api.piemadd.com/file/1" class="button">File 1</a><a href="https://demo.api.piemadd.com/file/2" class="button">File 2</a><p>'+data+'<p></body></html>'
	data = data.replace('					', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
	data = data.replace('				', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
	data = data.replace('			', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
	data = data.replace('		', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
	data = data.replace('	', '|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--->')
	data = data.replace('''
''', '<br>')
	data = data.replace('<br><br>', '<br>')
	f = open("templates/rendered.html","w+")
	f.write(data)
	return data

def beet(data):
	data = yeet(data)
	data = data.replace()

f=open("tree2.txt", "r")
contents =f.read()
#print(contents)
#print(yeet(contents))
g = open("guru99.txt", 'w+')
g.write(yeet(contents))
g.close()
keep_alive()
?