-1
플라스크에서 사용할 독립형 파이썬 코드를 어떻게 링크합니까?파이썬 코드를 FLASK에 연결하기
예.
import sys
# By design, the patterns come in one per line piped in from STDIN
for line in sys.stdin.readlines():
line = line.strip()
# 1) Split the pattern into clauses.
# 2) Translate each clause into regex syntax
# 3) reassemble the full regex pattern
clauses = line.split("-")
regex_clause_array = []
for clause in clauses:
# re_clause: the incremental build-up of the clause into regex syntax
re_clause=None
# Convert the prosite negation into a regex inverted character class
if clause.startswith("{"):
neg_pieces = clause.split("}")
# neg_pieces[0][1:] is the character set for the negation
# neg_pieces[1] is the optional quantification
re_clause = "[^%s]%s" % (neg_pieces[0][1:], neg_pieces[1])
else:
re_clause = clause
# change the quantification parenthesis into regex curly-braces
re_clause = re_clause.replace(")","}")
re_clause = re_clause.replace("(","{")
# change wildcards from 'x' to '.'
re_clause = re_clause.replace("x",".")
# save the regex-syntax clause to the regex clause array
regex_clause_array.append(re_clause)
# add the leading and trailing slashes and concatenate all regex clauses
# together to form the full regex pattern
print ("/%s/" % ("".join(regex_clause_array)))
는 예를 들면 서열을 얻어 위의 코드 자체 작동
PX (2) -GESG (2) - [AS] 파이썬 정규식으로 변환 P. {2} GESG {2} AS ].
내가 알아낼 수없는 점은이 도구를 웹 도구로 연결하기 위해 플라스크를 사용하려고한다는 것입니다. 지금 가지고있는 것은 텍스트 상자와 제출 버튼이 있지만 위 코드를 라우팅 앱에 연결하지 않은 간단한 웹 페이지입니다.
작업 할 파일 당신 '가져 오기 :
당신은 당신이 뭔가를 할 수있는 지금에 버튼을 제출
처럼 뷰 내에서 사용할 수 있습니다 '가장 중요한 것은 당신이 가져올 수있는 함수에 주요 기능을 가지고 있고,'if __name__ == '__main __':'을 사용하여 가져온다면 그 함수가 실행되는 것을 피하기 위해서입니다. – tripleee