Timepass with code
35 subscribers
3 photos
7 links
If you're looking for an enjoyable way to pass the time and develop some cool skills, why not try coding? You never know what you might be capable of creating!
Download Telegram
Channel created
#php
List Assignment in PHP

$string = "Martha:18";
[$name, $age] = explode(":", $string);
echo $name; // Output: Martha

Require php version >= 7.1

(If you are using older version then use list() construct )

$string = "Martha:18";
list($name, $age) = explode(":", $string);
echo $name; // Output: Martha
#http_status_response
HTTP status codes along with their corresponding names:

100 Continue
101 Switching Protocols
102 Processing

200 OK
201 Created
202 Accepted
204 No Content
206 Partial Content

300 Multiple Choices
301 Moved Permanently
302 Found
304 Not Modified
307 Temporary Redirect
308 Permanent Redirect

400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
405 Method Not Allowed
409 Conflict
410 Gone
429 Too Many Requests

500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
505 HTTP Version Not Supported

Docs: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#successful_responses
❤2
✨No one will tell you anything or everything about this field, It’s a long strange path but you have to travel it alone with little help from others.❤️
Please open Telegram to view this post
VIEW IN TELEGRAM
❤501👏1
Timepass with code pinned «✨No one will tell you anything or everything about this field, It’s a long strange path but you have to travel it alone with little help from others.❤️»
#python
#flask
Today I'm gonna show you about flask.

Requirements & Setup
Q/Of course, we need Python — 3.7 would be great

2/Pycharm community IDE because it’s awesome & free

3/Once you have the IDE, create a project. I named mine todo-flask. How creative!!

4/virtualenv — if you’re using Pycharm you don’t have to worry about this.

5/Installing flask using pip install flask

If you know the basics of Flask and wanna jump right in and build the app.

Let’s just check if our setup is fine by writing a “hello world” program. Create an app.py file under your project. You can name it anything other than calling your file flask.py since it will create a conflict with the actual flask package we installed.
todo-flask
     |_ app.py

Write down code below on app.py.
from flask import Flask

app = Flask(name)

@app.route("/")

def hello():
return "Hello World!"


if
name == 'main':
app.run(debug=True)


Run it from terminal.By default, flask runs a local server at port 5000.

python app.py

Enjoy
Timepass with code
#python #flask Today I'm gonna show you about flask. Requirements & Setup Q/Of course, we need Python — 3.7 would be great 2/Pycharm community IDE because it’s awesome & free 3/Once you have the IDE, create a project. I named mine todo-flask. How creative!!…
#python
#flask
#Bonuse part

Hello With Your Name
@app.route("/<name>") # at the end point /<name>
def hello_name(name): # call method hello_name
return "Hello "+ name # which returns "hello + name

Let’s hit http://localhost:5000/martha
 we will get a 404 error.
#python
#Ternary
Today I'm showing you usages of else if

Let’s take the example of writing a small code to check if the person is a watchable or not, based on his age. Simply, initiating a variable age.
age = 18

Using ternary conditional, this code is reduced to only a single line.
print("18+ site allowed for you") if age>18 else print("Not for you")

Whereas, the same logic can be implemented in the if-else as below.
if age>18:
print("18+ site allowed for you")
else:
print("Not for you")

Clearly, Ternary conditional makes the code 75% shorter and also improves the readability.
#php
#Tooltip

Tooltip is "an HTML concept for displaying additional information about the currently selected element."
When a visitor hovers the mouse pointer over an element, this trick displays the additional information supplied by the site's creator.

Syntax:
<span title="Can you see this? This is the tooltip.:)">Drag Your Mouse Over Me!</span>

Output:
After done comment ❤️
#php
Replace String In PHP

$string = "hey sexy girl";

$newString = str_replace("sexy", "girl girl", $string);
echo $newString; // Output: "hey girl girl girl"
#python
#flask
#api
FastAPI is a modern web framework developed in Python using by Flask.FastAPI offers all the standard features of an API building tool but it is not limited to this. It comes with a lot of flexibility such as backward WSGI mounting support which, most of the users, are not aware of.

Today Include Flask, Django, Dash, or any other WSGI
Below are the example contents for the dashboard.py file:

from dash import html from dash import dcc import dash_bootstrap_components as dbc import dash dash_app = dash.Dash(name, requests_pathname_prefix='/dashboard/', title='mirror Demo') header = dbc.Row( dbc.Col( [ html.Div(style={"height": 30}), html.H1("Demo", className="text-center"), ] ), className="mb-4", ) dash_app.layout = dbc.Container( [ header, ], fluid=True, className="bg-light", )

Fo
r instance, this dashboard would be mounted on the “/dashboard” path. See the contents of the main.py file below:
from fastapi import FastAPI from fastapi.middleware.wsgi import WSGIMiddleware from demo_dash import dash_app import uvicorn app = FastAPI() app.mount("/dashboard", WSGIMiddleware(dash_app.server)) @app.get('/') def index(): return "Hello" if name == "main": uvicorn.run("main:app", host='127.0.0.1', port=8000, reload=True)

If anyone visits the dashboard route, all those requests would be temporarily redirected to the dash server.