Guest User

Untitled

a guest
Nov 3rd, 2020
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from flask import Flask, request, render_template
  2. app = Flask(__name__, template_folder=' templates')
  3.  
  4. class check:
  5.     def check(code):
  6.         #some inits
  7.         #================================
  8.  
  9.         result = ""
  10.  
  11.  
  12.         lines = code.split('\n')
  13.         # \r is in end of each line. broken af.
  14.         for i in range(len(lines)):
  15.             lines[i] = lines[i][:len(lines[i])-1] #takes out last 2
  16.  
  17.  
  18.         comma = ',r ,s ,t ,u ,v ,w ,x ,y ,z ,@ ,0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9'
  19.         comma += ',a ,b ,c ,d ,e ,f ,g ,h ,i ,j ,k ,l ,m ,n ,o ,p ,q'
  20.         comma = comma.split(' ')
  21.         codeseg = {
  22.             "parts":["; --------------------------","; Your code here"],
  23.             "location":0
  24.         }
  25.         dataseg = ["; --------------------------","; Your variables here"],
  26.            
  27.        
  28.  
  29.         #================================
  30.  
  31.         #result += ("'your variables here' comment missing / is not in the right place.<br /> ")
  32.  
  33.         for i in range(len(lines)):
  34.             if lines[i] == "":
  35.                 result += (f'line {i+1} is empty<br />')
  36.            
  37.             for form in comma:
  38.                 if form in lines[i]:
  39.                     result += (f'need space after comma in line {i+1}<br />')
  40.  
  41.             #Checks for CODESEG  so I could know where it is at
  42.  
  43.             if lines[i] == "CODESEG":
  44.                 codeseg["location"] = i
  45.  
  46.         if not (lines[0][0] == ';'):
  47.             result += ("Name not in first line.<br />")
  48.  
  49.         if not ((lines[codeseg["location"]+4] == lines[codeseg["location"]+6] == codeseg["parts"][0]) & (lines[codeseg["location"]+5] == codeseg["parts"][1])):
  50.             result += ("'your code here' comment missing / is not in the right place.<br />")
  51.  
  52.         if not "Name not in first line.<br />" in result:
  53.             if not ((lines[5] == lines[7] == dataseg[0]) & (lines[6] == dataseg[1])):
  54.                 result += ("'your variables here' comment missing / is not in the right place.<br />")
  55.         else:
  56.             if not ((lines[4] == lines[6] == dataseg[0]) & (lines[5] == dataseg[1])):
  57.                 result += ("'your variables here' comment missing / is not in the right place.<br />")
  58.  
  59.         if result != "":
  60.             result += 'see <a herf="http://bit.ly/baseASM"> the instructions of writing in base format</a>'
  61.        
  62.         return(result)
  63.  
  64.  
  65. @app.route("/send", methods=["GET", "POST"])
  66. def send():
  67.     if request.method == "POST":
  68.         code = request.form["code"]
  69.  
  70.         return render_template("code.html", ERRS=check.check(code))
  71.  
  72.     return render_template("index.html")
  73.  
  74. if __name__ == "__main__":
  75.     app.run()
RAW Paste Data Copied