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.
Timepass with code
#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…
#python
#flask
#api
#Bonuse part

Mount different FastAPI apps for different routes

Below are the contents for the apiv1.py file (sub-application 1):

from fastapi import FastAPI apiv1 = FastAPI() @apiv1.get('/returnName') def index(): return {"Name": "Mirror demo"}

And here is the code for the apiv2.py file (sub-application 2):

from fastapi import FastAPI apiv2 = FastAPI() @apiv2.get('/returnLocation') def index(): return {"Location": "Bangladesh"}

Now, we can mount both of these sub-applications in the master application. See the code for the master.py file:

from fastapi import FastAPI from apiv1 import apiv1 from apiv2 import apiv2 import uvicorn app = FastAPI() app.mount("/api/v1", apiv1) app.mount("/api/v2", apiv2) @app.get('/') def index(): return "Hello" if name == "main": uvicorn.run("master:app", host='127.0.0.1', port=8000, reload=True)

If you make requests to respective paths endpoints, the request will be handled by those sub-applications.
🎉1
#python
#userbot
#plugin
⚡𝗕𝗶𝗻 𝗰𝗵𝗲𝗰𝗸 𝘂𝘀𝗲𝗿 𝗯𝗼𝘁 𝗽𝗹𝘂𝗴𝗶𝗻
♻️𝗗𝗲𝘃: @yourmirrorz
⚡ƑìӀҽ Ӏìղҟ: https://t.me/Yourmirrorz_bot?start=VQxGBklqb9ZIhmm7
𝐣𝐮𝐬𝐭 𝐝𝐨 .install
𝗘𝗻𝗷𝗼𝘆 𝗺𝘂𝘀𝘁 𝗦𝗵𝗮𝗿𝗲 𝘄𝗶𝘁𝗵 𝗰𝗿𝗲𝗱𝗶𝘁.
Please open Telegram to view this post
VIEW IN TELEGRAM
👍2🥰2
#python
#flask
#api
💖𝗔𝗣𝗜𝘀 𝘂𝘀𝗶𝗻𝗴 𝗙𝗹𝗮𝘀𝗸

💻Installation

pipenv install flask
pipenv install flask-restplus

pip install flask
pip install flask-restplus


❤️Basics
🖥Import
I began by importing Flask from flask. I imported Api from flask_restplus to define the application and Resource, which is received as a parameter in the numerous project-defined classes.

from flask import Flask from flask_restplus import Api, Resource

⚡Define App

flask_app = Flask(name) app = Api(app = flask_app) name_space = app.namespace('main', description='Main APIs')

I defined a namespace here. 
The URL for the namespace in the preceding example is http://127.0.0.1:5000/main, and its Swagger description is Main APIs.

⚡Define APIs

@name_space.route("/") class MainClass(Resource): def get(self): return { "status": "Got new data" } def post(self): return { "status": "Posted new data" }

In the preceding example, the APIs are accessible at http://127.0.0.1:5000/main. The class is named MainClass and contains two methods: get() and post(). Whenever I make a GET call, I receive a response with the status field reading Got new data, whereas a POST call returns the status field reading Posted new data.

✅Run App

Now, everything is set up. The file is saved as basic.py.

pipenv shell
FLASK_APP=basic.py flask run


Using pip, you can use the following command.

FLASK_APP=basic.py flask run

End.😎
Please open Telegram to view this post
VIEW IN TELEGRAM
👍1