这条线解决了我的问题,
return send_from_directory('directory-path', file.filename)
完整代码
这是从烧瓶导入send_from_directory的
class uploadfileform(flaskform):
file = filefiel('file',validators = [inputRequired()))
submit = sumbtfield('download file')
@app.route('/',methods = ['get','post'])
def home_api():
form = UploadFileForm()
if form.validate_on_submit():
file = form.file.data
file.save(os.path.join(os.path.abspath(os.path.dirname(_file_)),app.config['UPLOAD_FOLDER'],secure_filename(file.filename)))
process_xl(os.path.join(os.path.abspath(os.path.dirname(_file_)),app.config['UPLOAD_FOLDER'],secure_filename(file.filename)))
download_file(os.path.join(os.path.abspath(os.path.dirname(_file_)),app.config['UPLOAD_FOLDER'],secure_filename(file.filename)))
return send_from_directory('directory-path', file.filename)
return render_template('index.html', form=form)
如果线通过两个点P1 =(x1,y1)和p2 =(x2,y2),则(x0,y0)与线的距离为:
因此您可以轻松地将此公式更改为DART
import 'dart:math';
main(){
double x0 = -2;
double x1 = 0;
double x2 = 5/3;
double y0 = 5;
double y1 = 5/4;
double y2 = 0;
double numerator = (((x2 - x1)*(y1-y0)) - ((x1-x0)*(y2-y1))).abs();
double denominator = sqrt(pow((x2-x1), 2) + pow((y2-y1), 2));
double result = numerator / denominator;
print(result); /// 1.7999999999999998
}
的数学来源: https://en.wikipedia.org/wiki/distance_from_a_point_to_a_a_line
递归调用sumpower3(num,power+1)
可以任意增加指数的值,从而导致堆栈溢出错误。要解决问题,请为此参数设置最大值 - log(num,3) - 并在其值超过该限制时终止递归。
public class Maim {
public static void main(String[] args) {
System.out.println(sumPower3(2296)); // true: 3^0 + 3^3 + 3^4 + 3^7 == 2296
System.out.println(sumPower3(2297)); // false
System.out.println(sumPower3(2298)); // true: 3^1 + 3^3 + 3^4 + 3^7 == 2298
}
private static boolean sumPower3(int num) {
return sumPower3(num, 0, Math.log(num)/Math.log(3.0)); // set limit for power
}
private static boolean sumPower3(int num, int power, double limit) {
if(num==0) {
return true;
}
if(num<0 || power > limit) { // check limit for power
return false;
}
return sumPower3((int)(num-Math.pow(3, power)), power+1, limit) || sumPower3(num, power+1, limit);
}
}
问题对我解决了。实际上是我的码头图像。我应该使用jetty:9-jre8-openjdk 的而不是使用
,然后仅使用
类和Servlet Jars
可用对于我的申请。
在这里,它是完整的dockerfile
FROM maven as build
COPY src /home/app/src
COPY pom.xml /home/app
RUN mvn -f /home/app/pom.xml clean package
FROM jetty:9-jre8-openjdk
COPY --from=build /home/app/target/root.war /var/lib/jetty/webapps
EXPOSE 8080
CMD java -jar "$JETTY_HOME/start.jar"
改变您的想法是正确的方法是将该组件添加到app.js。
然后,使用redux,设置消息的值和布尔值等...以显示或隐藏组件。
现在,您可以使用Redux上的任何页面上更改消息的价值和iSshow的价值。
最佳答案很棒。这是我在常规 mysql setup:
// Storage
// Debian. Apparently already UTF-8
// Retrieval
// The MySQL database was stored in UTF-8,
// but apparently PHP was requesting ISO 8859-1. This worked:
// ***notice "utf8", without dash, this is a MySQL encoding***
mysql_set_charset('utf8');
// Delivery
// File *php.ini* did not have a default charset,
// (it was commented out, shared host) and
// no HTTP encoding was specified in the Apache headers.
// This made Apache send out a UTF-8 header
// (and perhaps made PHP actually send out UTF-8)
// ***notice "utf-8", with dash, this is a php encoding***
ini_set('default_charset','utf-8');
// Submission
// This worked in all major browsers once Apache
// was sending out the UTF-8 header. I didn’t add
// the accept-charset attribute.
// Processing
// Changed a few commands in PHP, like substr(),
// to mb_substr()
这就是!
您可以在自动缩放组上启用额外的指标,这将使您可以在Elastic Beanstalk监视页面上显示您正在寻找的计数指标。
从EC2控制台中,单击左侧导航中的自动缩放组,然后单击与您的Elastic Beanstalk应用程序关联的自动化组。 (如果您不知道自动缩放组,则可以通过单击一个EC2实例,选择标签选项卡并找到aws:autoscaling:groupName
值来找到它。)已经选择了正确的自动缩放组,请单击“监视”选项卡,然后选中“自动缩放组指标集合:启用”复选框。
启用后,请返回弹性豆键控制台,选择环境,然后单击左侧导航中的监视链接。在“监视”部分中,单击“编辑”,然后在“添加图”部分中为资源选择“ AwseBautoscalingGroup”。在“ CloudWatch Metric”选项下,您现在应该看到一些具有“组”前缀的新指标(请注意,出现新指标可能需要长达5分钟):
您可以创建一个具有“ GroupMaxSize”的度量,选择“最大值”为统计量,请参见Autoscaler随时间推移启动的实例计数。
使用 Muenchian分组仅获得独特的债权人:
xslt 1.0 <> xslt 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="creditor" match="Creditor" use="Contact/AddressBookUID" />
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="PolicyContactRoles">
<xsl:copy>
<xsl:for-each select="//Creditor[count(. | key('creditor', Contact/AddressBookUID)[1]) = 1]">
<Entry>
<AccountContactRole>
<Subtype>Creditor_De</Subtype>
<AccountContact>
<Contact>
<xsl:copy-of select="Contact/AddressBookUID"/>
</Contact>
</AccountContact>
</AccountContactRole>
<Subtype>PolicyCreditor_De</Subtype>
</Entry>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
在您的Docker-compose.yml文件中,将链接属性添加到您的WebServer服务:
https://docs.docker.com/compose/compose/networking/networking/#links
然后在您的查询字符串中,主机参数的值是您的数据库服务名称:
$mysqli = new mysqli("database", "mattia", "prova", "prova");
这是我最终使用的...
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.fu.bar/groupId>
<artifactId>server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>server</name>
<description>server</description>
<packaging>war</packaging>
<properties>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<jetty.version>11.0.9</jetty.version>
<jersey.version>3.0.5</jersey.version>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-cdi</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext.cdi</groupId>
<artifactId>jersey-cdi1x</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-core</artifactId>
<version>5.0.1.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/</contextPath>
</webApp>
</configuration>
</plugin>
</plugins>
</build>
</project>
某些东西使您的组件渲染不止一次,重复API获取。使用Effects的第二个参数可以使代码仅在更新某些变量时执行,请尝试使用它。
如果在执行此脚本的执行中,数据库操作仅执行一次,则无需实例化函数。只需获取要插入的名称的数量,然后使用php 准备的语句当然,以防止提交不适当的价值。
<?php
include "connection.php"; // needs to provide $mysqli
$number = ""; // default empty string for form value
// perform database operations first
if (!empty($_POST["number"]) && 0 < $_POST["number"]) { // qualify input
$number = $_POST["number"];
// Select random data
$get_names_stmt = $mysqli->prepare("SELECT data_firstname, data_lastname FROM data ORDER BY RAND() LIMIT ?");
$get_names_stmt->bind_param("i", $number); // integer, value
$get_names_stmt->execute();
$get_names_stmt->store_result(); // allows simultaneous insert
$get_names_stmt->bind_result($firstname, $lastname); // bind results to variables $firstname and $lastname
// Prepare to insert random data
$insert_names_stmt = $mysqli->prepare("INSERT INTO students (student_firstname, student_lastname) VALUES (?, ?)");
// bind to string variables $firstname and $lastname
$insert_names_stmt->bind_param("ss", $firstname, $lastname);
// loop random data selection, which provides variables $firstname and $lastname
while ($get_names_stmt->fetch()) {
// insert variables $firstname and $lastname
$insert_names_stmt->execute();
}
// wrap it all up
$get_names_stmt->close();
$insert_names_stmt->close();
$mysqli->close();
echo "You generated " . htmlspecialchars($number) . " new students !";
}
// if there is a $_POST["number"] variable, but it is not greater than 0
} else if (!empty($_POST["number"])) {
echo "Psss, try with a number greater than " . htmlspecialchars($_POST["number"] . ".");
}
?>
<form action="index.php" method="post">
<input type="number" name="number" min="0" value="<?=$number?>"></input>
<button type="submit" name="submit">Send</button>
</form>
顺便说一句,form ===客户端,php ===服务器端:
数据库注入从未在客户端上确保 - 永远不会发送到服务器的信任数据。曾经。
对于组合谓词,您已使用了位运算符expression.and
and expression.or bitwise and shift operators
在C#生成的结果中看起来像是
e => (e.Some > 1) & (e.Some < 10) | (e.Some == -1)
这样,EF也试图将位操作转换为SQL 。
而不是他们使用expression.andalso
和expression.orelse
布尔逻辑运算符
e => (e.Some > 1) && (e.Some < 10) || (e.Some == -1)
用于分析生成的表达式,我建议使用 Realable expressions.visualizers.visualizers ,您可能会自己发现错误。
您需要从表单中发送持久记录的ID字段,以便告诉Rails该对象已经在DB中。
另外,如果您希望用户具有删除标签的能力,则可以像这样修改代码。
在您的控制器中:
当用户想从帖子中删除任何标签时
You need to send the id field of persisted record from the form in order to tell rails that this object already in the db.
Also if you want user to have ability to remove tags you can modify your code like this.
and in your controller:
when the user want to delete any tag from post add
_destroy
parameter as '1' along with the id in the fields of that tag关于帖子和标签之间许多关系的问题(post_tag作为加入表)