mercredi 27 octobre 2021

How to update "static_path" and "xstatic_url" on the fly in tornado?

I'm new to Tornado, and trying to understand how can i update the static_path on the fly. (The Xstatic will be similar i guess)

For example:

Application([
    ('/static1/(.*)', tornado.web.StaticFileHandler, dict(path='static1')),
    ('/static2/(.*)', tornado.web.StaticFileHandler, dict(path='static2')),
])

I want to be able to update the path on the fly, inside the implementation of one of those Handlers.

Is that even possible? I know there are tools like static_url_prefix and update the static_path via settings of tornado. But can i do it on the fly? during execution of one the Handlers.

My usecase: Why do i need it?

When i am connecting via proxy server to load the web page of the application, there is a header of "/proxy/aHR0cHM6Ly8xMC4xLjMuMTAwOjQ0Mw==/" added to the URL in the browser, so it probably changes the relative path and i need to adjust the location of the static sources accordingly. (currently the html page cannot find the static sources when proxy used)

The problem:

I cannot know if there is a proxy or not,when tornado is first loaded. I know that only later when one of the handlers catches the regex url.

Maybe i can somehow concatenate the proxy header to the static_urlparameter?

Thanks.




Does it make sense to use django and npm in the same project?

I'm learning Django, I'm using Bootstrap etc. but I want to more customize for my website which build is bootstrap. I keep search and I saw that, if I want to customize bootstrap I should use bootstap-sass downloaded with npm.

Well, my question is "Does it make sense to use django and npm in the same project?" or "Should I use a different method?"




How to create a server using angular.min.js? [closed]

I'm trying to create an application by importing the angular.min.js file in html. I know how to create a server when I install angular the normal way using npm but in this case, I must import angular using the angular.min.js file. I am able to add it as a script in an html file. I can open the html file if I wanted to run that. Is there any way to deploy it on my localserver?




mardi 26 octobre 2021

How do I remove this graphical error for this button?

I am new to web development and I have a bug that I cannot seem to fix. Basically, I have a button that highlights when its hovered and it works but there is a small outline of the original color when hovered. I'm pretty sure this is not because of an outline or a border. The bug is displayed in the picture provided. Here is the code:

body {
    background-color: #2d2f31;
}

.start{
    width: 200px;
    height: 75px;
    border: none;
    color:black;
    background-color: beige;
    border-radius: 50px;
    box-shadow: inset 0 0 0 0 rgb(36, 36, 37);
    font-size: 15px;
    outline: 0;
    transition: 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
    cursor: pointer;
}

.start:hover{
    box-shadow: inset 200px 0 0 0 rgb(36, 36, 37);
    color: white;
}
<div class=buttondiv>
        <button onclick="coming('maintext', '#F0F');" class='start' >button</button>
 </div>

enter image description here




How to implement apple login on flutter web?

I want to implement apple login on flutter web project. The below package not supporting web, Anyone know how to implement the same on flutter web ?

https://pub.dev/packages/sign_in_with_apple




JS return structure

What is the difference between {} and ( ) in JavaScript's return statement?

const fruits = [
  {
    name: "FaceBook",
    nickname: "FB",
  },
  {
    name: "Youtube",
    nickname: "YT",
  },
  {
    name: "AmazonWebService",
    nickname: "AWS",
  },
];
const count = fruits.reduce((acc, cur) => {
  return { ...acc, [cur.nickname]: cur.name };  // What does {} of return mean here?
}, {});



I'm having some problem in focusing buttons

I'm having some problem with some button focus effects, although, I don't know if I'm supposed to use focus or not. So yesterday, I was trying to make a coffee roasters website. Now I have to create some options eg. What type of coffee the user wants and how much etc. So for that. I made h1s and below that I made some buttons. If they click on a button, It should change it's appearance so that the user knows it's selected now, when I am clicking on another button from another category, the previous category button is getting deselected because I used focus.I want all my categories to have different options and that the user can select any one option from a particular category but in terms of categories they can select a button from each category without deselecting the previous button from the previous category. I hope I didn't complicate the question but how can I do that? Please help me somebody!