예제 #1
0
 def post(self):
     code_id = request.json.get('code_id', None)
     title = request.json.get('title', None)
     subtitile = request.json.get('subtitle', '')
     from app.database_models import Threads
     if not Threads.verify_title(title):
         return ResponseClass.warn(ResponseCode.FORMAT_ERROR)
     thread = Threads()
     thread.user_id = g.user.id
     thread.title = title
     thread.code_id = code_id
     thread.subtitle = subtitile
     AppUtils.add_to_sql(thread).close()
     return ResponseClass.ok()
예제 #2
0
 def post(self):
     url = request.json.get("url", None)
     url = AppUtils.get_local_path(url)
     print("url:", url)
     session = AppUtils.get_session()
     from app.database_models import Code
     code = session.query(Code).filter_by(local_path=url).first()
     if code is None:
         return ResponseClass.warn(ResponseCode.FILE_NOT_EXIST)
     session.close()
     # 先存入CodeResult
     from app.database_models import CodeResult
     code_result = CodeResult()
     code_result.code_id = code.id
     code_result.user_id = g.user.id
     from app_config import code_manager
     session = AppUtils.add_to_sql(code_result)
     block = CodeBlock(user_id=code_result.user_id, task_id=code_result.id)
     session.close()
     return_value = code_manager.add_task(block)
     if return_value:
         return ResponseClass.ok_with_data({"code_id": code_result.code_id})
     else:
         return ResponseClass.warn(ResponseCode.SUBMIT_ERROR)