gpt4 book ai didi

php - 重定向到 Flask 中的 PHP 文件

转载 作者:太空宇宙 更新时间:2023-11-04 06:44:29 27 4
gpt4 key购买 nike

我正在使用 Flask 和 python 运行本地主机网站。我有一些 php 文件,我想在用户单击按钮时运行它们。问题是 Flask 无法将 PHP 文件识别为 PHP 代码,并且该代码在网页上显示为文本。它显示了所有 echo 语句的文本,但这些语句中的单词对应于代码中允许用户登录和注销网站的变量。我该怎么办?

Python 代码:

@app.route('/example.php')
def phpexample():
return render_template('example.php')

这显示了一个 html 页面,其中包含 echo 语句产生的文本。

PHP 代码(example.php):

<?php
require ('steamauth/steamauth.php');
?>
<html>
<head>
<title>Eliminate Phishers! Join Steap now</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script src="js/skel.min.js"></script>
<script src="js/init.js"></script>
<noscript>
<link rel="stylesheet" href="css/skel.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/style-wide.css" />
</noscript>
<!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->
</head>
<body>

<!-- Header -->
<div id="header">
<span class="logo icon fa-paper-plane-o"></span>
<h1>Welcome. This is Steap</h1>
<p>A website designed to help eliminate phishers
<br />
and hackers on Steam.</p>
</div>

<!-- Main -->
<div id="main">

<header class="major container small">
<h3>
<?php

if(!isset($_SESSION['steamid'])) {

echo "welcome guest! <br />\n please login ";
steamlogin(); //login button

} else {
include ('steamauth/userInfo.php');
$url = $steamprofile['profileurl'];
if ($steamprofile['personastate'] == 0) {
$state = '<span style="color:#616161";>(Offline)</span>';
$picture = '<span style="color:#616161";><img src="'.$steamprofile['avatarfull'].'" title = "" alt = ""></span>';

} else if ($steamprofile['personastate'] == 1) {
$state = '<span style="color:#006EFF";>(Online)</span>';
$picture = '<span style="border: 10px dotted #006EFF;"><img src="'.$steamprofile['avatarfull'].'" title = "" alt = ""></span>';
} else if ($steamprofile['personastate'] == 2) {
$state = '<span style="color:#006EFF";>(Busy)</span>';
$picture = '<span style="border-color:#006EFF border-style: solid";><img src="'.$steamprofile['avatarfull'].'" title = "" alt = ""></span>';
} else if ($steamprofile['personastate'] == 3) {
$state = '<span style="color:#006EFF";>(Away)</span>';
$picture = '<span style="border-color:#006EFF border-style: solid";><img src="'.$steamprofile['avatarfull'].'" title = "" alt = ""></span>';
} else if ($steamprofile['personastate'] == 4) {
$state = '<span style="color:#006EFF";>(Snooze)</span>';
$picture = '<span style="border-color:#006EFF border-style: solid";><img src="'.$steamprofile['avatarfull'].'" title = "" alt = ""></span>';
} else if ($steamprofile['personastate'] == 5) {
$state = '<span style="color:#006EFF";>(Looking to Trade)</span>';
$picture = '<span style="border-color:#006EFF border-style: solid";><img src="'.$steamprofile['avatarfull'].'" title = "" alt = ""></span>';
} else if ($steamprofile['personastate'] == 6) {
$state = '<span style="color:#006EFF";>(Looking to Play)</span>';
$picture = '<span style="border-color:#006EFF border-style: solid";><img src="'.$steamprofile['avatarfull'].'" title = "" alt = ""></span>';
}


//Protected content
echo "Welcome back" . "</br> </br>" . $picture ."</br>". $steamprofile['personaname'] . "</br>" .$state . "</br>". "Steam ID: ". $steamprofile['steamid'] . "</br>";
echo '<a href="' . $url . '">Steam Profile</a>' . "</br> </br>" . "<form action=\"steamauth/logout.php\" method=\"post\"><input value=\"Logout\" type=\"submit\" /></form>"; // Display their avatar!

}
?>
</h3>
</header>

<footer class="major container small">

<ul class="actions">
<li><a href="index.html" class="button">Get Phishers</a></li>
</ul>
</footer>

</div>

<!-- Footer -->
<div id="footer">
<div class="container small">

<header class="major last">
<h2>Questions or comments?</h2>
</header>

<p>Program not working? Not detecting the phishers properly? <br \> Send us a message. We'll be sure to back to you as soon as possible.</p>

<form method="post" action="#">
<div class="row collapse-at-2">
<div class="6u">
<input type="text" name="name" placeholder="Name" />
</div>
<div class="6u">
<input type="email" name="email" placeholder="Email" />
</div>
</div>
<div class="row">
<div class="12u">
<textarea name="message" placeholder="Message" rows="6"></textarea>
</div>
</div>
<div class="row">
<div class="12u">
<ul class="actions">
<li><input type="submit" value="Send Message" /></li>
</ul>
</div>
</div>
</form>

<ul class="icons">
<li><a href="#" class="icon fa-twitter"><span class="label">Twitter</span></a></li>
<li><a href="#" class="icon fa-facebook"><span class="label">Facebook</span></a></li>
<li><a href="#" class="icon fa-instagram"><span class="label">Instagram</span></a></li>
<li><a href="#" class="icon fa-github"><span class="label">Github</span></a></li>
<li><a href="#" class="icon fa-dribbble"><span class="label">Dribbble</span></a></li>
</ul>

<ul class="copyright">
<li>&copy; Steap 2014 All rights reserved.</li><li>Design: <a href="http://html5up.net">HTML5 UP</a></li>
</ul>

</div>
</div>

</body>
</html>

最佳答案

也许你应该在其他端口(如 8080)上运行 php 服务器(如 Apache 或其他),当你调用任何 php 文件时,从你的 flask 服务器向 php 服务器发出请求。从 php 服务器获得的结果显示在 flask 服务器上。我希望,你能找到如何从 Flask 向其他服务器发送请求的方法。

关于php - 重定向到 Flask 中的 PHP 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26823212/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com