小嗷兮

文章 评论 浏览 26

小嗷兮 2025-02-21 00:41:52

错误403-此Web应用程序已停止

  1. 如果您的开放式公共API受到Azure App Service的公开访问,则该错误可能会导致此错误可能导致此错误。您使用用于访问应用程序服务的应用程序的IP地址未列出或呼叫可能会阻止。

    • 按照官方文档在门户网站中检查您的访问限制规则

转到Azure Portal - > app->网络 - >访问限制 - >配置访问限制

“在此处输入图像说明”

  • 尝试添加0.0.0.0.0.0/0并授予访问访问权限每个人。稍后,根据您的需求,您可以施加限制。如果您在授权呼叫之前接到禁止电话,则可能会产生效果。

“在此处输入映像说明”

  1. 前门考虑了后端池中的所有后端,即使健康探索了任何一个人,它们失败了,流量在所有方面均匀分布。请参阅

    • 默认情况下检查您的优先级, 前门仅将流量发送到最高优先级后端
    • 检查您的参数使用默认值 重量为50
    • 尝试将两个后端放在同一后端池中,这两个都应该是可用的,然后您可以停止一个后端。选择具有最小延迟范围的后端。 默认设置延迟敏感性属性为0,这意味着该请求将始终转发到最快的后端。

3.尝试禁用 emforcecercertificatectificatenamecheck 来自Azure门户,并在添加到Orgin时检查您是否启用 cerficate主题名称验证必须是 启用 这个问题。

4.试图通过此 azure前门路由不工作 gitaranisharmsft-4262

学分 前门#先决条件“ rel =” nofollow noreferrer“> https://learn.microsoft.com/en-us/azure/frontdoor/quickstart-create-front-door#prerequisites

https://learn.microsoft.com/en-us/azure/frontdoor/routing-methods

The Error 403 - This web app is stopped

  1. This error may cause If your open public API is restricted from public access on Azure App Service. Your application's IP address that you are using to access the app service is not whitelisted or calls may be blocking.

Go to azure portal -> app -> Networking ->Access Restriction -> Configure Access Restrictions

enter image description here

  • Try adding 0.0.0.0/0 and granting access to everyone. Later, based on your needs, you can impose limits. It could have an effect if you receive banned calls before authorized calls.

enter image description here

  1. Front Door considers all backends in a backend pool to be healthy even if health probes for any one of them fail, and traffic is distributed evenly across them all. Please refer Health probes

    • Check your Priority By default, Front Door sends traffic only to the top priority backends
    • Check your parameter uses a default weight of 50
    • Try to put two backends in the same backend pool both should be availability then you can stop one backend. Choose backends with a range of least latency. The latency sensitivity property is by default set to 0, which means that the request will always be forwarded to the fastest backend.

3.Try to disable EnforceCertificateNameCheck from the Azure portal and while adding to Orgin check whether you are enable Cerficate subject name validation must be enable for Troubleshooting this issue.

4.Try to add virtual directory /path in your app service by this Azure front Door routing not working throws error credits by GitaraniSharmaMSFT-4262

For your Reference :

https://learn.microsoft.com/en-us/azure/frontdoor/quickstart-create-front-door#prerequisites

https://learn.microsoft.com/en-us/azure/frontdoor/routing-methods

Azure前门一直在路线一直到一个起源

小嗷兮 2025-02-20 14:44:17

您的XPath无效。您可以尝试

info_shelf_life = wd.find_element(By.XPATH, '//p[span="Shelf Life"]/following-sibling::div').text
info_country_of_origin = wd.find_element(By.XPATH, '//p[span="Country of Origin"]/following-sibling::div').text

获取所需的数据

Your XPath is invalid. You can try

info_shelf_life = wd.find_element(By.XPATH, '//p[span="Shelf Life"]/following-sibling::div').text
info_country_of_origin = wd.find_element(By.XPATH, '//p[span="Country of Origin"]/following-sibling::div').text

to get required data

python selenium-如何根据跨度标签中的文本提取元素?

小嗷兮 2025-02-20 07:38:19

我正在Ubuntu上运行Apache,我的问题是 /etc/apache2/mods-available/php5.conf 文件丢失了这一点:

<FilesMatch ".+\.ph(p[345]?|t|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>

我将其添加回了,PHP是正确解析的PHP文件。

I'm running Apache on Ubuntu and my issue was that the /etc/apache2/mods-available/php5.conf file was missing this:

<FilesMatch ".+\.ph(p[345]?|t|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>

I added it back in and php was parsing php files correctly.

PHP代码尚未执行,但代码在浏览器源代码中显示

小嗷兮 2025-02-19 13:29:28

局限性

MVC是一个非常广泛的话题,具有不同的理解,因此仅通过术语,即使在PHP应用程序的背景下,也很难正确回答。通常,您会参考MVC的现有实现,这不是您想自己做的情况(提示:读取可用的现有实现代码,以及您想了解更多信息)。

虽如此,您可以在答案结束时找到一些实用的“下一步”建议。

但是我也读到您的问题,即您担心HTML模板,也许这与您的示例如何有什么关系。因此,我开始就视图进行无约束力的讨论,然后转到路线和控制器。我主要关注讨论的模型层,至少您必须面对第三方库,否则您的应用程序结构将不会成为广泛功能的好主机,因此可以自动加载。

我在MVC中没有权力,我只使用了PHP中的一些早期实现,并且受其影响的应用程序,但从未完全实施。因此,请勿从讨论中读出任何建议,而仅仅是关于您的榜样以及我在PHP方面想到的。归根结底,您会找到自己的编程问题的答案。

我们走吧。

首先是建议/假设:您当然不想用控制器类实现视图创建,而是使用 View 类实现。控制器不“关心”它不会改变太大(MVC = Model View Controller)。

您可以通过引入 view 类并将 Controller :: createView()移动到 view :: create(creation()> (比较:提取/移动方法)。

然后,使用 require_once - 虽然它可以正常工作 - 仅当模板文件仅使用一次时才能工作。这当然不是您想在此处表达的内容(在讨论的后面,我们将看到现有示例也可以比有意想象的更容易发生),而是使用 requiend require (或<)代码> include 取决于您要处理错误的方式),因为它们将始终在文件中执行代码(有关重新定义控制器的潜在问题,请参见讨论第一次路由,然后在第二个自动加载中)。

除了明显的代码错误(错别字)外,您还需要寻求运行(这是探索应用程序php错误处理和监视的好机会),您仍然需要将控制器的输出数据传递到视图。

这可以称为查看模型,或者仅仅是对象(从广义上讲)持有要查看的数据(视图渲染)。 Just 需要/ include -ing(html布局)模板文件不够,因为它们可能包含HTML结构,但不包含控制器的输出数据。在模板的级别上,这通常是在变量中,例如超文本文档的标题:

<title>
  <?= htmlspecialchars($title, ENT_QUOTES | ENT_HTML5) ?>
</title>

如果这是函数的主体,则函数定义将是:

function outputHeader(string $title): void {
    # ...
}

由于我们没有需要模板文件,因此我们没有函数这只是模范。但是,我们可以创建一个通用函数,该函数处理需要模板文件并将变量传递到模板(比较 代码> )。在该层中,您还可以执行一些地面级别错误处理(尝试{} catch(throwable $ throwable){} 等)。对于初学者,您可以在 View 类中收集并将此类代码分组。

您也可能想要防止的是将视图绑定在控制器的构造方法( Controller :: __ construct(),简称CTOR)中。它迫使您拥有命名的视图(始终相同)使控制器取决于该视图。

这意味着您无法将任何视图配置为任何控制器。虽然在大多数情况下允许在混凝土实践中允许任何对任何关系的关系都是没有意义的,但它允许您实际具有层界限并不要太紧密(比较: spaghetti代码 1 ),并在更高级别上编写代码(在抽象等级中,比较间接层的)。

HTTP应用程序中的一个示例是进行内容谈判。这将发生在请求处理的级别上(示例中的更多路由器),例如HTTP客户端请求JSON而不是HTML。现在,HTML模板在这里不适合。但是,如果不是视图模板,控制器仍然可以完成工作。

为了使事物更加灵活(因此您可以更大的扩展使用),MVC模型的一个好处是通过控制器使用(并以某种程度地将模型的结果)使用。它可以帮助您定义这三个之间的清晰边界,并使它们彼此之间的分开更多(不太耦合)。

然后,路由可以协商并确定要汇集的内容,与您的示例中的示例相似,但与视图(模板)进行了扩展,可以为每个路由分配一个布局/模板。

由于这将与控制器相当 - 只是为了视图 - 让我们看看当前控制器不仅在视图中占据了位置(如果您发现缺陷或错误,请环顾四周,请环顾四周,他们通常不是一个地方,也不是一个人)。

当您已经配置路由器中的路由时,您将实际路由放入 Controller base-class( Controller :: get($ route,$ controler)) 。类似于 __构造()方法,这使控制器实现取决于路由,甚至实现路由。这很令人费解,肯定会变得尴尬。当您添加更多路线时,问题也存在问题,您会放松控制哪一个在每个控制器等内完成匹配时匹配。简而言之,虽然代码可能起作用,但在我看来,在另一个地方可能会受益。因为这是关于路由的,我脑海中脑海中的第一名将是路由器本身。然后,路由器可以完成实际工作,“执行路由”:

$router = new Router(); # <-- bootstrap
$router->get('/', 'home.contr.php'); # <-- prepare
$router->get('/home', 'home.contr.php'); # <-- prepare
$router->get('/about', 'about.contr.php'); # <-- prepare
$router->get('/portfolio', 'projects.contr.php'); # <-- prepare
$router->route(); # <-- do the work here

路由器 get()方法可以从外部保持不变,但是您只需将路线存储在内部,当您调用<<时代码> route()方法,该配置与您的请求实现匹配。

然后,您可以使用视图名称扩展路由器配置。

那时,您仍然可以将路由绑定到控制器和视图,但是您有一个中心位置(已配置/参数化)。控制器和视图彼此更加独立,您可以将自己的实现集中到比现在进入路由器的整体接线。

最后,在这里时,您的示例还显示了它对文件系统的依赖性,您为控制器和视图模板提供了一定的文件命名约定。虽然隐含地将代码放入文件中是必不可少的,但至少在您可以依靠PHP自动加载的控制器级别上的示例中。虽然您想自己写所有内容(例如不使用现成的MVC库),但我仍然建议使用某些标准,例如 autolododer(psr-4)并且作为天生的懒惰,使该应用程序成为 composer project (它具有 composer.json file)为作曲家允许您配置自动加载器,并且有一个定义明确的过程(您还可以更轻松地引入在应用程序逻辑中,您肯定需要的第三方库,因此这只是在很肯定的意义上是有意义的,只需使用Composer AutoLoader而无需任何要求)即可。

因此,您可以说控制器基本上是一个具有至少单个方法的类方法,而不是硬链接控制器PHP文件路径,而是该路由器可以调用的单个方法。随着自动加载器的操作,路由配置只需要引用该类别/方法和PHP,然后小心地加载课程。可以用。也许初学者的一个好的中间地面是每个班级有一个控制器,并且需要将其设备一个接口,以便您拥有合同(比较:编程与接口 1 2, 3 4 5 6 7 等)。然后,您可以简单地传递class-name并在 route()方法中处理实例化。

$router->get(
    /* route       */  '/', 
    /* $controller */  MyApp\MVC\Crontroller\Home::class, 
    /* $viewName   */  'home'
);
<?php

namespace MyApp\MVC\Controller;


class Home implements Interface {
    # ...
}
<?php
namespace MyApp\MVC\Controller;

interface Interface {
    public function invoke(InputParameter $params): InvocationResult
}

然后, route()可以检查接口以验证某些类可用作控制器( instanceof ),并且会知道如何 Invoke()控制器通过传递输入参数以接收可以进一步委派给模板层的结果。

还可以通过引入 InputParameter InvocationResult 实现(类/接口)来实现这一目标,从而有助于定义控制器部分的层边界。

然后,您可以为视图层做类似的操作较少的工程,首先使用控制器尝试,然后在路由中进行委派,直到您更多地了解实际要求(会话处理,身份验证,内容调用,重定向等)。

归根结底,您必须在这里做出自己的决定。

下一步建议

  1. 添加至少可以从开发环境中运行的至少一个测试标记“使用单个键盘 /单击”和简单的OK / FAIL结果(例如,您在Shell中执行的简单PHP脚本)
  2. 考虑如何考虑如何为了改善错误处理,您可以更快地了解缺陷(例如,引入异常并
  3. 首先修复错误,您的代码实际上应该首先运行(它可能无法完整地产生预期的结果,但至少应该运行 - 您的示例不得)
  4. 初始化作曲家/添加 composer.json 到您的项目
  5. ,然后将代码更改为您的喜好,这可以使其首先进行测试受益(比较单位测试

Limitations

MVC is a very broad topic with much different understanding so that by the term alone this is hard to answer properly - even in context of a PHP application. You normally refer to an existing implementation of MVC which is not the case here as you want to do it your own (Hint: Read code of existing implementations that is available and about you want to learn more).

Discussion

With that being said, you can find some practical "first next steps" suggestions at the end of the answer.

But I read your question as well that you're concerned about the HTML templates and perhaps also what this has to do with how you wrote your example. So I start a non-binding discussion about the View and then go over to Route and Controller. The Model layer I've kept out of the discussion mainly, at least for that you have to face third-party libraries as otherwise your application structure would not be a good host for broad functionality, this is touched by autoloading.

I have no authority in MVC, I just used some of the early implementations in PHP and applications influenced by them but never implemented it fully. So don't read out any suggestion from the discussion regarding it, it is merely about your example and what came to my mind in specific to PHP. At the end of the day it is you who will find the answer to your own programming questions.

Let's go.

A suggestion/assumption first: You certainly don't want to implement the view creation with the Controller class but with a View class. It would not change much just that the controller does not "care" about it (MVC = Model View Controller).

You can refactor (change) your code by introducing a View class and move the Controller::createView() to View::create() (compare: extract/move method).

Then using require_once - while it may work - it would only work if the template file is only used once. This is certainly not what you want to express here (and later in the discussion we'll see that with the existing example this can also more easily happen than perhaps intentionally thought), instead use require (or include depending on how you want to handle errors) as they will always execute the code in the file (for potential problems redefining controllers, see later in the discussion first routing and then second autoloading).

Apart from obvious code errors (typos) you'd need to address to get it to run (which is a good opportunity to explore PHP error handling and monitoring for your application) you still need to pass the output data of the controller to the view.

This can be so called view models or just objects (in the broader sense) holding the data to be viewed (rendered by the view). Just require/include-ing the (HTML layout) template files won't suffice as they may contain the HTML structure but not the controllers' output data. On the level of the templates this is typically in variables, e.g. the title of the hypertext document:

<title>
  <?= htmlspecialchars($title, ENT_QUOTES | ENT_HTML5) ?>
</title>

If this would be the body of a function, the function definition would be:

function outputHeader(string $title): void {
    # ...
}

As we don't have a function by requiring the template files, this is just exemplary. However we could create a generic function that handles requiring a template file and passing the variables to the template (compare include_helper()). In that layer you can also do some ground level error handling (try {} catch (Throwable $throwable) {} etc.). For starters you could collect and group such code in the View class.

What you also likely want to prevent is to bind the view within the controllers' constructor method (Controller::__construct(), ctor in short). It forces you to have a named view - and always the same - makes the controller dependent on that view.

That would mean you couldn't configure any view to any controller. While it wouldn't make sense in most cases to allow an any-to-any relationship here in the concrete practice, it allows you to actually have layer boundaries and to not couple things too tightly (compare: Spaghetti Code 1) and to write code on a higher level (in grade of abstraction, compare Layer of Indirection).

An example in a HTTP application would be to do content negotiation. This would happen on the level of request processing (more in the Router in your example), e.g. a HTTP client requests JSON instead of HTML. Now the HTML templates wouldn't fit here. But the Controller could still do the work if not the view template would be hard-encoded.

To keep things more flexible (so you can use it to a greater extend), one benefit of the MVC model is to use (and to a certain degree somehow pass the result of) the Model by the Controller to the View. It helps you define clear boundaries between those three and keep them more apart from each other (less coupled).

The routing then could negotiate and decide what to bring together, similar as in your example for the Controller already but extended with the View (template), each route could be assigned a layout/template.

As this would work quite the same as with the controller - just for the view - let's see where the current Controller not only is standing in the way for the view but already for the routing (if you find a flaw or bug, look around, often they are not in a single place and alone).

While you already configure the routes in the router, the actual routing you've put in the Controller base-class (Controller::get($route, $controller)). Similar to the __construct() method, this makes the Controller implementation dependent on the Route and even implements the routing. This is pretty convoluted and will certainly become awkward. There is also the problem when you add more routes you loose control which one matches as the matching is done within each Controller etc. . In short, while the code may be functional, it just seems to me it can benefit to be at a different place. As it's about the routing, first place that comes into my mind would be the Router itself. The Router then could do the actual work, "do the routing":

$router = new Router(); # <-- bootstrap
$router->get('/', 'home.contr.php'); # <-- prepare
$router->get('/home', 'home.contr.php'); # <-- prepare
$router->get('/about', 'about.contr.php'); # <-- prepare
$router->get('/portfolio', 'projects.contr.php'); # <-- prepare
$router->route(); # <-- do the work here

The Routers get() method then could stay the same from the outside but you would just store the routes inside and when you invoke the route() method, that configuration is matched against your request implementation.

You could then extend the router configuration with the view name.

It would be then that you still have bound a route to a controller and a view, however you have a central location where this is done (configured/parameterized). Controller and View are more independent to each other and you can concentrate more with their own implementation than the overall wiring which now moved into the router.

Finally while being here, what your example also shows is its dependence on the file-system, you have a certain file-naming convention for the controllers and also the view templates. While it is implicitly necessary to place the code into files, at least in your example on the level of the controllers you can already rely on PHP autoloading. While you want to write everything yourself (e.g. not using a ready-made MVC library), I'd still suggest to make use of some standards, like Autoloader (PSR-4) and as being inherently lazy, make the app a Composer project (it has a composer.json file) as Composer allows you to configure the autoloader and there is a well-defined process developing with it (you can also bring in more easily third-party libraries which you'll certainly need within your application logic, so this is just forward-thinking in a good sense, just start without any requirements just using the Composer autoloader).

So instead of hard-linking controller PHP file-paths, you could say instead that a controller basically is a class definition with at least a single method that the router is able to call. With the autoloader in action, the routing configuration would only need to reference that class/method and PHP then would take care to load the class. This could be done as strings (lazy-loading) or more explicit with the First class callable syntax (PHP 8.1). A good middle-ground for starters perhaps is to have one Controller per class and require to have it an interface so that you have a contract (compare: programming against interfaces 1, 2, 3, 4, 5, 6, 7 etc.). You can then simply pass the class-name and handle the instantiation in the route() method.

$router->get(
    /* route       */  '/', 
    /* $controller */  MyApp\MVC\Crontroller\Home::class, 
    /* $viewName   */  'home'
);
<?php

namespace MyApp\MVC\Controller;


class Home implements Interface {
    # ...
}
<?php
namespace MyApp\MVC\Controller;

interface Interface {
    public function invoke(InputParameter $params): InvocationResult
}

The route() then could check for the interface to verify some class can be used as a controller (instanceof) and would know how to invoke() the controller by passing the input parameters to receive the result that can be further delegated to the template layer.

This is made possible by also introducing the InputParameter and InvocationResult implementations (classes/interfaces) that help to define the layer boundary of the Controller part.

You can then do something similar for the View layer however the output comes relatively late and you're perhaps not yet settled with it (and you may have different template "engines" depending on use-case) so I would leave it more thin and less engineered and try with the Controllers first and do the delegation in the routing until you learn more about your actual requirements (Session handling, Authentication, Content-Negotiation, Redirects etc.).

At the end of the day you have to make your own decisions here.

Next Steps Suggestions

  1. Add at least one test-script that you can run from your development environment "with a single key-press / click" and simple OK/Fail result (e.g. a simple PHP script that you execute in the shell)
  2. Think about how to improve the error handling so you learn about defects faster (e.g. introduce exception and
  3. Fix the bugs first, your code should actually run first of all (it might not produce the intended results in full but it should at least run - your example does not)
  4. Init Composer / add composer.json to your project
  5. Then change the code to your liking which can benefit having it under test first (compare Unit Tests)

当前在PHP中构建的方式是HTML布局结构吗?

小嗷兮 2025-02-19 12:32:58

我已经找到了使用SWRL规则来执行此操作的方法。我的事情可能还有另一种使用财产链的方式,但我没有深入研究。
我这样做的方式需要安装插件才能使用SWRL规则,然后转到Windows - &gt;选项卡,然后选择SWRL选项卡。
然后,这很容易,只需一些Google即可查看语法并编辑一些预制的Google搜索规则。

I already find a way to do it using SWRL rules. I thing there might be another way around using property chains, but i didnt go deep into it.
The way i did it required to install a plugin to work with SWRL rules and then go to Windows -> Tabs and select SWRL tab.
Then it is pretty easy, just some google to see the syntax and edit some premade googled rules.

蛋白质;推断,如果两个公寓位于同一地址,则它们在同一建筑物中

小嗷兮 2025-02-18 21:35:41

最糟糕的解决方案是使用堆栈小部件,添加圆形容器并设置 headingRowColor 透明。

我设置 headingRowheight 60和圆形容器高度为40,所以我需要将圆形容器 margin(60-40)/2 = 10设置为使其成为垂直中心。

@override
  Widget build(BuildContext context) {
    TextStyle cellStyle = TextStyle(color: Colors.white);
    TextStyle rowHeaderStyle = TextStyle(color: Colors.greenAccent);
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Stack(
        children: [
          // Add rounded container
          Container(
            width: MediaQuery.of(context).size.width,
            // set height 40
            height: 40,
            margin: EdgeInsets.symmetric(vertical: 10,horizontal: 14),
            decoration: BoxDecoration(
                color: Colors.blueGrey,
                borderRadius: BorderRadius.circular(20)
            ),
          ),
          Container(
            width: MediaQuery.of(context).size.width,
            child: DataTable(
              columnSpacing: 35,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(20),  // this only make bottom rounded and not top
                color: const Color(0xE61B1D1C),
              ),
              // set heading row height 60
              headingRowHeight: 60,
              headingRowColor: MaterialStateProperty.all<Color>(Colors.transparent),
              columns: [
                DataColumn(label: Text("Referral Code", style: TextStyle(fontWeight: FontWeight.w400, fontSize: 12, color: Color(0xF2979797)), softWrap: true, textAlign: TextAlign.center,)),
                DataColumn(label: Text("Share (%)\nYou-Friend", style: TextStyle(fontWeight: FontWeight.w400, fontSize: 12, color: Color(0xF2979797)), softWrap: true, textAlign: TextAlign.center,)),
                DataColumn(label: Text("Friends", style: TextStyle(fontWeight: FontWeight.w400, fontSize: 12, color: Color(0xF2979797)))),
                DataColumn(label: Text("Vol. (USD)", style: TextStyle(fontWeight: FontWeight.w400, fontSize: 12, color: Color(0xF2979797)))),
              ],
              rows: [
                DataRow(cells: [DataCell(Text('ADHJKGO',style: rowHeaderStyle,)), DataCell(Text('100-0',style: cellStyle,)), DataCell(Text('0',style: cellStyle)), DataCell(Text('100',style: cellStyle))]),
                DataRow(cells: [DataCell(Text('CXMDJEO',style: rowHeaderStyle)), DataCell(Text('50-50',style: cellStyle)), DataCell(Text('0',style: cellStyle)), DataCell(Text('2000',style: cellStyle))]),
              ],
            ),
          ),
        ],
      ),
    );
}

中构建它

我在桌面

The worst solution is to use stack widget, add rounded Container and set headingRowColor transparent.

I set headingRowHeight 60 and rounded Container height is 40, so I need to set rounded Container margin (60-40)/2 = 10 to make it vertical center.

@override
  Widget build(BuildContext context) {
    TextStyle cellStyle = TextStyle(color: Colors.white);
    TextStyle rowHeaderStyle = TextStyle(color: Colors.greenAccent);
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Stack(
        children: [
          // Add rounded container
          Container(
            width: MediaQuery.of(context).size.width,
            // set height 40
            height: 40,
            margin: EdgeInsets.symmetric(vertical: 10,horizontal: 14),
            decoration: BoxDecoration(
                color: Colors.blueGrey,
                borderRadius: BorderRadius.circular(20)
            ),
          ),
          Container(
            width: MediaQuery.of(context).size.width,
            child: DataTable(
              columnSpacing: 35,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(20),  // this only make bottom rounded and not top
                color: const Color(0xE61B1D1C),
              ),
              // set heading row height 60
              headingRowHeight: 60,
              headingRowColor: MaterialStateProperty.all<Color>(Colors.transparent),
              columns: [
                DataColumn(label: Text("Referral Code", style: TextStyle(fontWeight: FontWeight.w400, fontSize: 12, color: Color(0xF2979797)), softWrap: true, textAlign: TextAlign.center,)),
                DataColumn(label: Text("Share (%)\nYou-Friend", style: TextStyle(fontWeight: FontWeight.w400, fontSize: 12, color: Color(0xF2979797)), softWrap: true, textAlign: TextAlign.center,)),
                DataColumn(label: Text("Friends", style: TextStyle(fontWeight: FontWeight.w400, fontSize: 12, color: Color(0xF2979797)))),
                DataColumn(label: Text("Vol. (USD)", style: TextStyle(fontWeight: FontWeight.w400, fontSize: 12, color: Color(0xF2979797)))),
              ],
              rows: [
                DataRow(cells: [DataCell(Text('ADHJKGO',style: rowHeaderStyle,)), DataCell(Text('100-0',style: cellStyle,)), DataCell(Text('0',style: cellStyle)), DataCell(Text('100',style: cellStyle))]),
                DataRow(cells: [DataCell(Text('CXMDJEO',style: rowHeaderStyle)), DataCell(Text('50-50',style: cellStyle)), DataCell(Text('0',style: cellStyle)), DataCell(Text('2000',style: cellStyle))]),
              ],
            ),
          ),
        ],
      ),
    );
}

I build it in desktop

enter image description here

flutter DataTable标题如何在顶部标题上?

小嗷兮 2025-02-18 19:27:06

您可以在阅读时通过日期变量读取它。

这是动态代码,您也不需要硬码日期,只需将其附加到路径上

>>> df.show()
+-----+-----------------+-----------+----------+
|Sr_No|          User_Id|Transaction|        dt|
+-----+-----------------+-----------+----------+
|    1|paytm 111002203@p|       100D|2022-06-29|
|    2|paytm 111002203@p|        50C|2022-06-27|
|    3|paytm 111002203@p|        20C|2022-06-26|
|    4|paytm 111002203@p|        10C|2022-06-25|
|    5|             null|         1C|2022-06-24|
+-----+-----------------+-----------+----------+

>>> df.write.partitionBy("dt").mode("append").parquet("/dir1/dir2/sample.parquet")

>>> from datetime import date
>>> from datetime import timedelta
>>> today = date.today()
#Here i am taking two days back date, for one day back you can do (days=1)
>>> yesterday = today - timedelta(days = 2)
>>> two_days_back=yesterday.strftime('%Y-%m-%d')

>>> path="/di1/dir2/sample.parquet/dt="+two_days_back
>>> spark.read.parquet(path).show()
+-----+-----------------+-----------+
|Sr_No|          User_Id|Transaction|
+-----+-----------------+-----------+
|    2|paytm 111002203@p|        50C|
+-----+-----------------+-----------+

you can read it by passing date variable while reading.

This is dynamic code, you nor need to hardcode date, just append it with path

>>> df.show()
+-----+-----------------+-----------+----------+
|Sr_No|          User_Id|Transaction|        dt|
+-----+-----------------+-----------+----------+
|    1|paytm 111002203@p|       100D|2022-06-29|
|    2|paytm 111002203@p|        50C|2022-06-27|
|    3|paytm 111002203@p|        20C|2022-06-26|
|    4|paytm 111002203@p|        10C|2022-06-25|
|    5|             null|         1C|2022-06-24|
+-----+-----------------+-----------+----------+

>>> df.write.partitionBy("dt").mode("append").parquet("/dir1/dir2/sample.parquet")

>>> from datetime import date
>>> from datetime import timedelta
>>> today = date.today()
#Here i am taking two days back date, for one day back you can do (days=1)
>>> yesterday = today - timedelta(days = 2)
>>> two_days_back=yesterday.strftime('%Y-%m-%d')

>>> path="/di1/dir2/sample.parquet/dt="+two_days_back
>>> spark.read.parquet(path).show()
+-----+-----------------+-----------+
|Sr_No|          User_Id|Transaction|
+-----+-----------------+-----------+
|    2|paytm 111002203@p|        50C|
+-----+-----------------+-----------+

在Pyspark中阅读划分的镶木记录

小嗷兮 2025-02-18 14:53:02

尝试此示例:

server.py (服务器等待 msg1 msg2 并相应地响应):

async def runServer():
    server = await websockets.serve(onConnect, "localhost", port=8765)
    print("Server started listening to new connections...")
    await server.wait_closed()


async def onConnect(ws):
    try:
        while True:
            message = await ws.recv()

            if message == "msg1":
                await ws.send("response from server 1")
            elif message == "msg2":
                await ws.send("response from server 2")
    except websockets.exceptions.ConnectionClosedOK:
        print("Client closed...")


if __name__ == "__main__":
    asyncio.run(runServer())

client.py.py (首先发送 msg1 ,打印响应,然后 发送 msg2 并打印响应):

async def connect():
    async with websockets.connect(
        "ws://localhost:8765",
    ) as ws:

        print("Connected to the switch.")

        await ws.send("msg1")
        response = await ws.recv()

        print("Response from the server:", response)

        await ws.send("msg2")
        response = await ws.recv()

        print("Response from the server:", response)


if __name__ == "__main__":
    asyncio.run(connect())

客户端打印:

Connected to the switch.
Response from the server: response from server 1
Response from the server: response from server 2

Try this example:

server.py (server waits for msg1 and msg2 and responds accordingly):

async def runServer():
    server = await websockets.serve(onConnect, "localhost", port=8765)
    print("Server started listening to new connections...")
    await server.wait_closed()


async def onConnect(ws):
    try:
        while True:
            message = await ws.recv()

            if message == "msg1":
                await ws.send("response from server 1")
            elif message == "msg2":
                await ws.send("response from server 2")
    except websockets.exceptions.ConnectionClosedOK:
        print("Client closed...")


if __name__ == "__main__":
    asyncio.run(runServer())

client.py (first sends msg1, prints response and afterwards sends msg2 and prints response):

async def connect():
    async with websockets.connect(
        "ws://localhost:8765",
    ) as ws:

        print("Connected to the switch.")

        await ws.send("msg1")
        response = await ws.recv()

        print("Response from the server:", response)

        await ws.send("msg2")
        response = await ws.recv()

        print("Response from the server:", response)


if __name__ == "__main__":
    asyncio.run(connect())

The clients prints:

Connected to the switch.
Response from the server: response from server 1
Response from the server: response from server 2

Python Websocket等待回复

小嗷兮 2025-02-18 03:01:29

因此,我找到了解决方案:

我不必模拟 uservice.js 文件,而是 keycloak-js -module。为此,我创建了一个名为 __模拟__ 的文件夹,然后放入模拟的模块中。开玩笑会自动知道从模拟文件夹而不是节点模块调用keycloak-js。

src/模拟/keycloak-js.js:

class Keycloak {
    token = "token available";
    url = null;
    realm = null;
    clientId = null;
    tokenParsed = {
        preferred_username: "dummy user",
    }

    constructor(keycloakConfig) {
        this.url = keycloakConfig.url;
        this.realm = keycloakConfig.realm;
        this.clientId = keycloakConfig.clientId;
    }

    login = () => {
        this.token = "Logged in";
    }

    logout = () => {
        this.token = null;
    }

    updateToken = () => {
        this.token = "Logged in";
        return new Promise((resolve, reject) => {
            if (!!this.token) {
                resolve();
            } else {
                reject();
            }
        })
    }

    init = (startupConfig) => {
        
    }

    hasRealmRole = (role) => {
        return true;
    }
}

export default Keycloak;


So I found the solution:

I do not have to mock the UserService.js file but more the keycloak-js-module. For this I create a folder called __mocks__ and put in my mocked module. Jest will automatically know to call keycloak-js from the mocks folder instead of node-modules.

src/mocks/keycloak-js.js:

class Keycloak {
    token = "token available";
    url = null;
    realm = null;
    clientId = null;
    tokenParsed = {
        preferred_username: "dummy user",
    }

    constructor(keycloakConfig) {
        this.url = keycloakConfig.url;
        this.realm = keycloakConfig.realm;
        this.clientId = keycloakConfig.clientId;
    }

    login = () => {
        this.token = "Logged in";
    }

    logout = () => {
        this.token = null;
    }

    updateToken = () => {
        this.token = "Logged in";
        return new Promise((resolve, reject) => {
            if (!!this.token) {
                resolve();
            } else {
                reject();
            }
        })
    }

    init = (startupConfig) => {
        
    }

    hasRealmRole = (role) => {
        return true;
    }
}

export default Keycloak;


React Jest:如何模拟服务?

小嗷兮 2025-02-18 01:13:25

Amy和Pineapple☑️错误线:MongonetWorkerror:连接机构在ConnectionFailureError 取消了

const mongoose = require("mongoose");


mongoose.connect("mongodb://localhost:27017/fruitsDB",{useNewUrlParser: true});
 
const fruitSchema = new mongoose.Schema({
    name: {
        type: String,
        required: [true, "Please check your data entry, no name specified!"]
    },
    rating: {
        type: Number,
        min: 1,
        max: 10
    },
    review: String
});
 
const Fruit = mongoose.model("Fruit", fruitSchema);
 
const pineapple = new Fruit({
    name: "Pineapple",
    rating: 9,
    review: "Great fruit"
});
 
 
const personSchema = new mongoose.Schema({
    name: String,
    age: Number,
    favouriteFruit: fruitSchema
});
 
const Person = mongoose.model("Person", personSchema);
 
const person = new Person({
    name: "Amy",
    age: 12,
    favouriteFruit: pineapple
});
 
pineapple.save();
person.save();

您只需要保存菠萝和人 最后 对我有用。

☑️Solution to the establishing relationship problem between Amy and Pineapple☑️ ERROR Line: MongoNetworkError: connection establishment was cancelled at connectionFailureError

const mongoose = require("mongoose");


mongoose.connect("mongodb://localhost:27017/fruitsDB",{useNewUrlParser: true});
 
const fruitSchema = new mongoose.Schema({
    name: {
        type: String,
        required: [true, "Please check your data entry, no name specified!"]
    },
    rating: {
        type: Number,
        min: 1,
        max: 10
    },
    review: String
});
 
const Fruit = mongoose.model("Fruit", fruitSchema);
 
const pineapple = new Fruit({
    name: "Pineapple",
    rating: 9,
    review: "Great fruit"
});
 
 
const personSchema = new mongoose.Schema({
    name: String,
    age: Number,
    favouriteFruit: fruitSchema
});
 
const Person = mongoose.model("Person", personSchema);
 
const person = new Person({
    name: "Amy",
    age: 12,
    favouriteFruit: pineapple
});
 
pineapple.save();
person.save();

You just need to save both the pineapple and the person together in the end and it worked for me.

Mongonetworkerror:连接机构被取消

小嗷兮 2025-02-17 21:48:02

PHP全局变量 $ _ POST 包含发布到服务器的所有数据。当前, HardWareComputername 只是客户端的变量。您需要将其添加到您的表单中,以便将其发布到服务器上。只有这样,您就可以从 $ _ POST ['HARDWARECOMPUTERNAME'] 中读取它。

做到这一点的一种方法:

  1. 向您的表格中添加另一个隐藏元素:

     &lt; input type =“隐藏” name =“ hardwarecomputername” id =“ computername”&gt;
     
  2. 对话框结果后,将输入值添加到新创建的元素:

      if(hardwarecomputername){
        document.getElementById(“ computername”)。value = hardwarecomputername;
        document.getElementById(“ ComputerRenameForm”)。submit();
    }
     

完成:

<form id="computerRenameForm" action="computerRename" method="post">
    <input type="hidden" name="rename" value="">
    <input type="hidden" name="computerID" value="<?= htmlspecialchars($computer->id) ?>">
    <input type="hidden" name="hardwareComputerName" id="computerName">
</form>
<button onclick="confirmComputerRename()"><i class="bi bi-trash-fill"></i> Umbenennen</button>

<script>
    function confirmComputerRename()
    {
    (async () => {
        const { value: hardwareComputerName } = await Swal.fire({
            html: "Zum Umbenennen muss der Computer online sein.<br>Das Gerät wird neu gestartet.",
            icon: 'warning',
            input: 'text',
            inputAttributes: {maxlength: 15},
            showCancelButton: true,
            confirmButtonText: 'OK',
            confirmButtonColor: '#ff0000',
            cancelButtonText: 'Abbrechen',
            reverseButtons: false
        })
    
        if (hardwareComputerName) {
            document.getElementById("computerName").value = hardwareComputerName;
            document.getElementById("computerRenameForm").submit();
        }
    })()
}
</script>

The PHP global variable $_POST contains all the data that are posted to the server. Currently, hardwareComputerName is only a variable on the client side. You need to add it to your form, so it can be posted to the server. Only then you'll be able to read it from $_POST['hardwareComputerName'].

One way to do it:

  1. Add another hidden element to your form:

    <input type="hidden" name="hardwareComputerName" id="computerName">
    
  2. After your dialog result, add the input value to the newly created element:

    if (hardwareComputerName) {
        document.getElementById("computerName").value = hardwareComputerName;
        document.getElementById("computerRenameForm").submit();
    }
    

Complete:

<form id="computerRenameForm" action="computerRename" method="post">
    <input type="hidden" name="rename" value="">
    <input type="hidden" name="computerID" value="<?= htmlspecialchars($computer->id) ?>">
    <input type="hidden" name="hardwareComputerName" id="computerName">
</form>
<button onclick="confirmComputerRename()"><i class="bi bi-trash-fill"></i> Umbenennen</button>

<script>
    function confirmComputerRename()
    {
    (async () => {
        const { value: hardwareComputerName } = await Swal.fire({
            html: "Zum Umbenennen muss der Computer online sein.<br>Das Gerät wird neu gestartet.",
            icon: 'warning',
            input: 'text',
            inputAttributes: {maxlength: 15},
            showCancelButton: true,
            confirmButtonText: 'OK',
            confirmButtonColor: '#ff0000',
            cancelButtonText: 'Abbrechen',
            reverseButtons: false
        })
    
        if (hardwareComputerName) {
            document.getElementById("computerName").value = hardwareComputerName;
            document.getElementById("computerRenameForm").submit();
        }
    })()
}
</script>

从形式和SweetAlert到PHP的张贴变量?

小嗷兮 2025-02-17 19:01:16

没关系,这只是我花了一段时间才弄清楚了,对不起。

#include&lt; stdio.h&gt;

int var = 1;

int var1 = 2;

int main()
{
while (var<100)
{
    var+=var1;
    var1+= var;
printf("%d\n", var);
}

}

Nevermind here it is, It just took me a while to figure it out, sorry.

#include <stdio.h>

int var = 1;

int var1 = 2;

int main()
{
while (var<100)
{
    var+=var1;
    var1+= var;
printf("%d\n", var);
}

}

我可以在C中写一个fib(我有一个示例),但是有一种更有效的方法

小嗷兮 2025-02-17 18:35:58

好的,这完全无关。
- 因此,基本上,您需要提出一个将提供HTML代码的GET请求。

- 在此HTML代码中,您会找到一个CSRF令牌。您将使用Regex将其放入字符串中。

- 您将创建一个返回用户名,密码和CSRF代币的POST登录请求。

您现在已记录!!!

关于处理cookie,只要保留相同的retclient对象,RestSharp就会自动进行。我将它们放在字符串数组中,然后使用string.format在请求中使用它们

Ok so it was totally not about oauth at all.
-So basically, you need to make a GET request that will deliver an html code.

-In this html code you will find an csrf token. You will use regex to put it in a string.

-You will create a POST login request that return username, password and csrf token.

You're now logged!!!

About handling cookies, restsharp do it automatically as long as you keep the same RestClient object. I put them in a string array and use them in the request using String.Format

RESTSHARP帖子问题

小嗷兮 2025-02-17 18:20:22

您必须导入特质 std :: io :: Read ,然后可以调用 read> read :: read_to_to_string 才能读取文件的内容。

use std::fs::File;
use std::io::{BufReader, Read};

fn main() {
    let mut input: BufReader<File> = BufReader::new(File::open("cube.obj").expect("didn't work"));
    let mut str = String::new();
    input.read_to_string(&mut str).expect("cannot read string");
    println!("input: {}", str);
}

You have to import the trait std::io::Read and then can call Read::read_to_string to read the content of the file.

use std::fs::File;
use std::io::{BufReader, Read};

fn main() {
    let mut input: BufReader<File> = BufReader::new(File::open("cube.obj").expect("didn't work"));
    let mut str = String::new();
    input.read_to_string(&mut str).expect("cannot read string");
    println!("input: {}", str);
}

RUST:有没有办法转换BufReader&lt; file&gt;到字符串?

小嗷兮 2025-02-17 07:49:33

您可以使用 getplatform() href =“ https://capacitorjs.com/docs/core-apis/web#isnativeplatform” rel =“ nofollow noreferrer”> isnativeplatform() 检查环境:

if (Capacitor.isNativePlatform()) {
  // Native app running on Android or iOS
}

You can use getPlatform() or isNativePlatform() to check the environment:

if (Capacitor.isNativePlatform()) {
  // Native app running on Android or iOS
}

在Angular Web应用程序中,使用电容器在移动设备上运行略有不同的代码吗?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文