当前位置:网站首页>Precondition end of script headers or end of script output before headers
Precondition end of script headers or end of script output before headers
2022-06-29 17:57:00 【Meng Langlang】
In the test Python DB-API When using process scripts , The following error occurred during access :
see Apache journal , The error message is as follows :
Premature end of script headers: dblink.py
perhaps
End of script output before headers: dblink.py
dblink.py The script is as follows :
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import MySQLdb
# Open database connection
db = MySQLdb.connect("localhost", " Database user name ", " Database password ", " database ", charset='utf8mb4')
# Use cursor() Method get operation cursor
cursor = db.cursor()
# Use execute Method execution SQL sentence
cursor.execute("SELECT VERSION()")
# Use fetchone() Method to get a piece of data
data = cursor.fetchone()
print "Database version : %s " % data
# Close database connection
db.close()
Found through debugging , There should be no mark HTTP The end of the header message results in , The program is modified as follows :
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import MySQLdb
# Open database connection
db = MySQLdb.connect("localhost", " Database user name ", " Database password ", " database ", charset='utf8mb4')
# Use cursor() Method get operation cursor
cursor = db.cursor()
# Use execute Method execution SQL sentence
cursor.execute("SELECT VERSION()")
# Use fetchone() Method to get a piece of data
data = cursor.fetchone()
print "Content-type:text/html"
print # Blank line , Tell the server to end the header
print "Database version : %s " % data
# Close database connection
db.close()
among ," Content-type:text/html" by HTTP Part of the head , It will send it to the browser and tell the browser the content type of the file , use print Output a blank line to tell the server to end the header information .
The results are as follows :
边栏推荐
- 第42期:MySQL 是否有必要多列分区
- Analyze the implementation principle of zero copy mechanism, applicable scenarios and code implementation
- 小迈科技 X Hologres:高可用的百亿级广告实时数仓建设
- Function independent watchdog (iwdg) experiment based on stm32f103zet6 Library
- 数字孪生能源系统,打造低碳时代“透视”眼
- VB. Net read / write NFC ntag tag source code
- 从一个被应用商店坑了的BUG说起
- reflex
- 基于STM32F103ZET6库函数定时器中断实验
- 设置双击运行 jar 文件
猜你喜欢
Let's start with a bug that was cheated by the app store
Walk with love, educate and run poor families, and promote public welfare undertakings
【WebDriver】使用AutoIt上传文件
剑桥大学教授:经常吃早餐害处多,很危险 - 知乎
两种Controller层接口鉴权方式
The soft youth under the blessing of devcloud makes education "smart" in the cloud
Face recognition 4- research on Baidu commercial solutions
小程序容器是什么技术?能助力物联网企业红海突围?
ISO 32000-2 国际标准7.7
人脸识别4-百度商用方案调研
随机推荐
阿里云不同账号新旧服务器镜像迁移数据迁移同步
基于STM32F103ZET6库函数定时器中断实验
kubekey2.2.1 kubernetes1.23.7离线包制作+harbor部暑并上传镜像
Xiaomai technology x hologres: high availability of real-time data warehouse construction of ten billion level advertising
力扣每日一题 06.29 两数相加
【Try to Hack】Cookie和Session
How to use the chart control of the b/s development tool devextreme - customize the axis position?
Parental delegation mechanism
Teach you how to install the latest version of mysql8.0 database on windows, nanny level teaching
lodash深拷贝使用
SSH协议学习笔记
面试中问最常问的海量数据处理你拿捏了没?
Web Scraping with Beautiful Soup for Data Scientist
数字孪生能源系统,打造低碳时代“透视”眼
回文子串的最大长度(字符串哈希+二分)
Force deduction daily question 06.29 add two numbers
What are the usage scenarios for locks in MySQL
reflex
填充每个节点的下一个右侧节点指针[利用好每个点->尽可能降低时空复杂度]
Bloom filter: