├── LICENSE ├── README.md └── app.py /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2 | 3 | Any upload, copying and use of the works is forbidden. 4 | 5 | - Read codes are allowed. 6 | - Cut, copying code is not allowed. 7 | - Uploading files is not allowed. 8 | - Downloading for storing is not allowed. 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Link Shortener 2 | 3 | Link Shortener is a free and useful service to create a short link then redirect to other links. 4 | 5 | ## Using 6 | 7 | The service will soon be available on the Internet. 8 | 9 | We will publish the URL. (SOON) 10 | 11 | ## Foundation 12 | 13 | **`Client Side`** 14 | 15 | * Pure CSS 16 | * Vanilla Javascript 17 | 18 | **`Librarys`** 19 | * Bootstrap v4.3.1 (https://getbootstrap.com/) 20 | * Vue.js v2.6.8 21 | * Vue Resource v1.5.1 22 | 23 | **`Web Server`** 24 | * Nginx 1.14.2 25 | * Jan 26 | 27 | **`Database`** 28 | * NoSql 29 | 30 | **`Operation System`** 31 | * Unix BSD 32 | 33 | **`Server Side`** 34 | * Ruby Programming Language 35 | * Rust Programming Language 36 | * Go Programming Language 37 | * C Programming Language 38 | * Python Programming Language 39 | * **ET Programming Language (Final version)** 40 | 41 | It was also tested with **Ruby**, **Rust**, **Go** technologies. 42 | 43 | ## Files 44 | 45 | ``` 46 | . 47 | ├── asset 48 | │ ├── ads.jpg 49 | │ ├── bootstrap.css 50 | │ ├── bootstrap.css.map 51 | │ ├── index.html 52 | │ ├── logo.svg 53 | │ ├── script.js 54 | │ ├── style.css 55 | │ ├── vue-resource.js 56 | │ └── vue.js 57 | ├── build 58 | │   ├── api.o 59 | │   ├── array.o 60 | │   ├── cgi.o 61 | │   ├── data.o 62 | │   ├── database.o 63 | │   ├── decodequery.o 64 | │   ├── layout.o 65 | │   ├── main 66 | │   ├── multipart.o 67 | │   ├── random.o 68 | │   ├── request.o 69 | │   ├── route.o 70 | │   └── socket.o 71 | ├── build.sh 72 | ├── serve 73 | ├── serve.pid 74 | ├── source 75 | │ ├── api.et 76 | │ ├── api.eth 77 | │ ├── array.et 78 | │ ├── array.eth 79 | │ ├── cgi.et 80 | │ ├── cgi.eth 81 | │ ├── data.et 82 | │ ├── data.eth 83 | │ ├── database.et 84 | │ ├── database.eth 85 | │ ├── decodequery.et 86 | │ ├── decodequery.eth 87 | │ ├── main.et 88 | │ ├── main.eth 89 | │ ├── multipart.et 90 | │ ├── multipart.eth 91 | │ ├── request.et 92 | │ ├── request.eth 93 | │ ├── route.et 94 | │ ├── route.eth 95 | │ ├── socket.et 96 | │ ├── socket.eth 97 | │ ├── random.et 98 | │ ├── random.eth 99 | │ ├── layout.et 100 | │ └── layout.eth 101 | └── test 102 | ├── decodequery 103 | ├── decodequery.et 104 | └── test.eth 105 | 106 | 4 directories, 54 files 107 | ``` 108 | 109 | ## Copyright 110 | 111 | Any upload, copying and use of the works is forbidden. 112 | 113 | - Read codes are allowed. 114 | - Cut, copying code is not allowed. 115 | - Uploading files is not allowed. 116 | - Downloading for storing is not allowed. 117 | 118 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | from flask import Response 3 | from flask import render_template 4 | from flask import Blueprint 5 | # from flask import request 6 | from flask import request, jsonify 7 | import uuid 8 | import json 9 | # from app import app, mongo 10 | from pymongo import MongoClient 11 | from bson import json_util 12 | from flask import redirect 13 | 14 | MONGODB_HOST = 'localhost' 15 | MONGODB_PORT = 27017 16 | DB_NAME = 'Asrez' 17 | COLLECTION_LINK="Link" 18 | 19 | class flaskLocal(Flask): 20 | def process_response(self, response): 21 | # response.headers 22 | return(response) 23 | 24 | app = flaskLocal(__name__) 25 | 26 | #app.config.SERVER_NAME = 'asrez.base:80' 27 | #app.config 28 | 29 | @app.route('/') 30 | def index(): 31 | return render_template('index.html') 32 | 33 | @app.route('/single') 34 | def single(): 35 | return render_template('single.html') 36 | 37 | @app.route('/projects/') 38 | def projects(): 39 | return 'The project page' 40 | 41 | @app.route('/about') 42 | def about(): 43 | return 'The about page' 44 | 45 | 46 | # doc_count = col.count_documents(filter, skip=skip) 47 | # results = col.find(filter).sort(sort).skip(skip).limit(limit) 48 | 49 | linkRegistered= [ 50 | "api", 51 | "login", 52 | "register", 53 | "exit", 54 | "signin", 55 | "signout", 56 | ] 57 | 58 | @app.route('/link/', methods=['GET','POST'], defaults={'identifier':None}) 59 | @app.route('/link//',methods=['GET']) 60 | def link(identifier): 61 | mainSite="http://asrez.base/" 62 | site="http://asrez.base/link/" 63 | if identifier == None or identifier == '': 64 | if request.method == "GET": 65 | return render_template('link_index.html', error=False, method=request.method, random=uuid.uuid4().hex.upper()[0:7].lower(), site=site, mainSite=mainSite) 66 | else: 67 | url=request.form.get("url") 68 | identifier=request.form.get("identifier") 69 | if url and identifier: 70 | allow=True 71 | for item in linkRegistered: 72 | if identifier in item: 73 | allow=False 74 | break 75 | if allow: 76 | exists=collectionLink.count_documents({"identifier":identifier}) 77 | if exists == False: 78 | mydict = {"url":url,"identifier":identifier} 79 | x = collectionLink.insert_one(mydict) 80 | if x.inserted_id: 81 | message="Success" 82 | status=True 83 | return render_template('link_index.html', error=False, message=message, method=request.method, identifier=identifier, status=status, site=site, mainSite=mainSite) 84 | else: 85 | status=False 86 | message="Problem occur in generate link!" 87 | return render_template('link_index.html', error=False, message=message, method=request.method, identifier=identifier, status=status, site=site, mainSite=mainSite) 88 | else: 89 | status=False 90 | message="Aleady Exists!" 91 | return render_template('link_index.html', error=False, message=message, method=request.method, identifier=identifier, status=status, site=site, mainSite=mainSite) 92 | else: 93 | status=False 94 | message="Identifier is not Allow!" 95 | return render_template('link_index.html', error=False, message=message, method=request.method, identifier=identifier, status=status, site=site, mainSite=mainSite) 96 | else : 97 | status=False 98 | message="Failed alert!" 99 | return render_template('link_index.html', error=False, message=message, method=request.method, identifier=identifier, status=status, site=site, mainSite=mainSite) 100 | elif identifier in linkRegistered: 101 | if identifier == "api": 102 | return render_template('link_api.html', site=site, mainSite=mainSite) 103 | else: 104 | return "Soon..." 105 | else: 106 | get=collectionLink.find_one({"identifier":identifier}) 107 | if get != None: 108 | # return get["url"] 109 | return redirect(get["url"], code=302) 110 | else: 111 | message="Wrong link!" 112 | return render_template('link_index.html', error=True, message=message, identifier=identifier, site=site, mainSite=mainSite) 113 | 114 | 115 | if __name__ == '__main__': 116 | connection = MongoClient(MONGODB_HOST, MONGODB_PORT) 117 | collectionLink = connection[DB_NAME][COLLECTION_LINK] 118 | # app.run(host='asrez.com', port=80, debug=False) 119 | app.run(port=80) 120 | 121 | --------------------------------------------------------------------------------