Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, request, render_template
- app = Flask(__name__, template_folder=' templates')
- class check:
- def check(code):
- #some inits
- #================================
- result = ""
- lines = code.split('\n')
- # \r is in end of each line. broken af.
- for i in range(len(lines)):
- lines[i] = lines[i][:len(lines[i])-1] #takes out last 2
- comma = ',r ,s ,t ,u ,v ,w ,x ,y ,z ,@ ,0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9'
- comma += ',a ,b ,c ,d ,e ,f ,g ,h ,i ,j ,k ,l ,m ,n ,o ,p ,q'
- comma = comma.split(' ')
- codeseg = {
- "parts":["; --------------------------","; Your code here"],
- "location":0
- }
- dataseg = ["; --------------------------","; Your variables here"],
- #================================
- #result += ("'your variables here' comment missing / is not in the right place.<br /> ")
- for i in range(len(lines)):
- if lines[i] == "":
- result += (f'line {i+1} is empty<br />')
- for form in comma:
- if form in lines[i]:
- result += (f'need space after comma in line {i+1}<br />')
- #Checks for CODESEG so I could know where it is at
- if lines[i] == "CODESEG":
- codeseg["location"] = i
- if not (lines[0][0] == ';'):
- result += ("Name not in first line.<br />")
- if not ((lines[codeseg["location"]+4] == lines[codeseg["location"]+6] == codeseg["parts"][0]) & (lines[codeseg["location"]+5] == codeseg["parts"][1])):
- result += ("'your code here' comment missing / is not in the right place.<br />")
- if not "Name not in first line.<br />" in result:
- if not ((lines[5] == lines[7] == dataseg[0]) & (lines[6] == dataseg[1])):
- result += ("'your variables here' comment missing / is not in the right place.<br />")
- else:
- if not ((lines[4] == lines[6] == dataseg[0]) & (lines[5] == dataseg[1])):
- result += ("'your variables here' comment missing / is not in the right place.<br />")
- if result != "":
- result += 'see <a herf="http://bit.ly/baseASM"> the instructions of writing in base format</a>'
- return(result)
- @app.route("/send", methods=["GET", "POST"])
- def send():
- if request.method == "POST":
- code = request.form["code"]
- return render_template("code.html", ERRS=check.check(code))
- return render_template("index.html")
- if __name__ == "__main__":
- app.run()
Add Comment
Please, Sign In to add comment