Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /smjkzsl_IRAILS /apps /app /controllers /test_controller.py
| from irails import route,api,Request,Response,BaseController,application,WebSocket,WebSocketDisconnect,UploadFile,File | |
| from typing import Any, Dict ,List | |
| from pydantic import conlist | |
| class TestController(BaseController): | |
| async def upload_test(self, files: List[UploadFile] = File(...) ): | |
| p = {} | |
| for file in files: | |
| path,url = await self._save_upload_file(file) | |
| p[file.filename] = [path,url] | |
| return {"files":p} | |
| def react_home(self ): | |
| ''' | |
| :title React Home | |
| ''' | |
| return self.view() | |
| async def home(self,request:Request): | |
| ''' | |
| :title Home | |
| ''' | |
| c = self.session.get('home',1) | |
| c = c+1 | |
| self.cookies["a"] = c | |
| if c>10: | |
| del self.cookies["a"] | |
| c = 0 | |
| self.session['home'] = c | |
| text = "Hello World! I'm in FastapiMvcFramework" | |
| router_map = {} | |
| for app_name in application.apps: | |
| if not app_name in router_map: | |
| router_map[app_name]={} | |
| router_map[app_name]['title'] = application.apps[app_name]['manifest']['title'] or app_name | |
| for func in application.apps[app_name]['route_map']: | |
| item = application.apps[app_name]['route_map'][func] | |
| if item['doc']: | |
| if (not 'nav' in item['doc'] ) or ('nav' in item['doc'] and item['doc']['nav'].lower() != 'false'): | |
| router_map[app_name][func] = application.apps[app_name]['route_map'][func] | |
| else: | |
| router_map[app_name][func] = application.apps[app_name]['route_map'][func] | |
| app_name = application.title | |
| #访问其它模块中的控制器函数,实例化一个控制器需要提供两个参数,request(请求对象,不能为空) 和 response(可为None) | |
| from irails.apps.system_admin.controllers.user_controller import UserController | |
| u = UserController(request=self.request,response=self.response) | |
| aa = await u.current() | |
| return self.view( ) | |
| return self.view() | |
| def get_legacy_data(self): | |
| """:title XML(only bruce)""" | |
| data = """<?xml version="1.0"?> | |
| <shampoo> | |
| <Header> | |
| Apply shampoo here. | |
| </Header> | |
| <Body> | |
| You'll have to use soap here. | |
| </Body> | |
| </shampoo> | |
| """ | |
| return self.view(content=data,media_type="application/xml") | |
| def chatgpt(self): | |
| """ | |
| :title Chat(only alice) | |
| """ | |
| return self.view() | |
Xet Storage Details
- Size:
- 2.86 kB
- Xet hash:
- 23f800f25595a575f5265337c2216105425d58ffbbdc18b643625a92623f8d73
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.