post请求

图片测试

我与影子孤独终老i 提交于 2019-11-28 02:06:17
记录: async:false,jquery是否异步的参数,如果设置成false,一旦请求的action出现异常,页面很容易死掉。 页面乱码:有时候页面与页面间用post传递参数 中文可能出现乱码,可在html代码中加入<globalization requestEncoding="utf-8" responseEncoding="utf-8" /> window.showModalDialog 页面post提交不出现新窗口的方法在头部增加<base target="_self"/> JFinal 1.3 急速java web框架,EHCache缓存 <%=java.lang.System.getenv("VCAP_SERVICES")%>获取cloudfoundry数据库信息<img src='"/></img> 来源: http://www.cnblogs.com/leogen/archive/2013/04/17/3026722.html

模拟POST请求

徘徊边缘 提交于 2019-11-28 00:47:12
h t m l = ′ ′ ; f o r e a c h ( html = ''; foreach ( h t m l = ′ ′ ; f o r e a c h ( native as $key => $val){ KaTeX parse error: Expected '}', got 'EOF' at end of input: …"<input name='{ key}’ type=‘text’ value=’{$val}’ />"; } echo "<form style='display:none;' id='form1' name='form1' method='post' action='{$tjurl}'>{$html}</form> <script type='text/javascript'>function load_submit(){document.form1.submit()}load_submit();</script>"; exit(); KaTeX parse error: Expected '}', got 'EOF' at end of input: …bmit' action='{ this->gateway}’ method=‘post’>"; foreach ($this->config as $key => $value) {

Django rest framework 序列化组件

99封情书 提交于 2019-11-27 23:56:04
最近在DRF的序列化上踩过了不少坑,特此结合官方文档记录下,方便日后查阅。 【01】前言    serializers是什么?官网是这样的”Serializers allow complex data such as querysets and model instances to be converted to native Python datatypes that can then be easily rendered into JSON, XML or other content types. “翻译出来就是,将复杂的数据结构,例如ORM中的QuerySet或者Model实例对象转换成Python内置的数据类型,从而进一步方便数据和json,xml等格式的数据进行交互。    根据实际的工作经验,我来总结下serializers的作用:    1.将queryset与model实例等进行序列化,转化成json格式,返回给用户(api接口)。   2.将post与patch/put的上来的数据进行验证。   3.对post与patch/put数据进行处理。(后面的内容,将用patch表示put/patch更新,博主认为patch更贴近更新的说法)   简单来说,针对get来说,serializers的作用体现在第一条,但如果是其他请求,serializers能够发挥2

配置 admin 页面

亡梦爱人 提交于 2019-11-27 23:35:50
创建 blog 的管理后台 首先是 blog 这个 App,其中定义了 3个 Model,分别是 Category、Post 和 Tag。先创建 admin 页面,其代码需要写到 blog/admin.py 这个文件中。 编写 Tag 和 Category 的管理后台 from django.contrib import admin from .models import Post, Category, Tag @admin.register(Category) class CategoryAdmin(admin.ModelAdmin): list_display = ('name', 'status', 'is_nav', 'created_time') fields = ('name', 'status', 'is_nav') @admin.register(Tag) class TagAdmin(admin.ModelAdmin): list_display = ('name', 'status', 'created_time') fields = ('name', 'status') 这点代码就完成了 Tag 和 Category 的 admin 配置,可以尝试运行一下看看效果,然后再解释其中代码的作用。 首先,激活虚拟环境。先创建超级用户的用户名和密码,执行 python

百度编辑器上传文件的bug

 ̄綄美尐妖づ 提交于 2019-11-27 23:02:23
在用百度编辑器上传文件过程中 出现问题1: 原因是POST 请求 body 的大小超过了被限制的大小,在php.ini做如下修改(将post_max_size大小改为大于你要上传的文件的大小)即可: 出现问题2: 原因是 用户上传单文件的大小超过了被限制的大小 在php.ini做如下修改(将post_max_size大小改为大于你要上传的文件的大小)即可: 来源: 51CTO 作者: 喝醉的熊 链接: https://blog.51cto.com/13550695/2412084

Django 之 CBV

China☆狼群 提交于 2019-11-27 22:17:11
Django 中有两种编写方式,FBV 和 CBV,那么什么是 FBV,CBV 又是什么呢? 一、什么是 CBV FBV(function base views) 就是在视图里使用函数处理请求(常见)。 CBV(class base views) 就是在视图里使用类处理请求。 示例: 1、 project/urls.py from django.contrib import admin from django.urls import path from app.views import IndexView urlpatterns = [ path('admin/', admin.site.urls), path('index/', IndexView.as_view()), ] 2、 app/views.py from django.shortcuts import render, HttpResponse from django.views import View class IndexView(View): def get(self, request, *args, **kwargs): print('get') return HttpResponse('GET') def post(self, request, *args, **kwargs): print('post')

Django--FBV + CBV

点点圈 提交于 2019-11-27 21:49:30
目录 FBV + CBV FBV(function bases views) FBV中加装饰器相关 CBV(class bases views) CBV中加装饰器相关 FBV + CBV django中请求处理方式有2种:FBV 和 CBV FBV(function bases views) 就是在视图里使用函数处理请求,如下: # urls.py from django.conf.urls import url, include from app01 import views urlpatterns = [ url(r'^index/', views.index), ] # views.py from django.shortcuts import render def index(req): if req.method == 'POST': print('method is :' + req.method) elif req.method == 'GET': print('method is :' + req.method) return render(req, 'index.html') 注意此处定义的是函数【def index(req):】 <!--index.html--> <!DOCTYPE html> <html lang="en"> <head> <meta

HTTP协议

杀马特。学长 韩版系。学妹 提交于 2019-11-27 18:56:09
请求到相应的基本过程: http:超文本传输协议(hyper text transfer protocol) 规范了浏览器和服务器之间的数据交互 特点:简单快速,灵活,无连接,无状态,支持B/S和C/S架构 http:1.1之后支持可持续连接 get请求参数直接显示在地址栏的,post不显示 get请求不安全,post安全 get请求参数有大小限制,post没有 响应格式: 状态码分类: 常见响应状态吗: 来源: https://www.cnblogs.com/zrmj/p/11373203.html

django路由层

為{幸葍}努か 提交于 2019-11-27 17:48:07
目录 上传文件 Jason模块的使用 FBV(function base view) 与CBV(class base view) 虚拟环境 伪静态 路由分发 反向解析 路由层 无名分组 有名分组 上传文件 注意的点: print('path:',request.path) print('full_path:',request.get_full_path()) path: /upload_file/ full_path: /upload_file/?name=jason 简单的文件上传 前端需要注意的点: 1.method需要指定成post 2.enctype需要改为formdata格式 后端暂时需要注意的是 1.配置文件中注释掉csrfmiddleware中间件 2.通过request.FILES获取用户上传的post文件数据 file_obj = request.FILES.get('my_file') print(file_obj.name) with open(file_obj.name,'wb') as f: for line in file_obj.chunks(): f.write(line) 先在day56项目文件的urls里进行测试 from django.contrib import admin from django.urls import path,re

django表单

て烟熏妆下的殇ゞ 提交于 2019-11-27 17:15:06
表单是交互性网站的支柱。 本文内容包括django对表单提交数据的访问,有效性检查以及其他处理,还有HttpRequest对象和Form对象。 一、HttpRequest的URL相关信息 定义views.py def current_url_view(request): return HttpResponse("Welcome to the page at %s,host is %s,full path is %s,is_secure is %s" % (request.path,request.get_host(),request.get_full_path(),request.is_secure())) 可以显示出: Welcome to the page at /url/,host is 10.1.101.227:9000,full path is /url/,is_secure is False 二、request.META 显示所有META,在views.py里增加函数display_meta。 def display_meta(request): values = request.META.items() values.sort() html = [] for k, v in values: html.append('<tr><td>%s</td><td>%s</td>