Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
linroex committed Oct 21, 2021
1 parent 1116021 commit 581bef7
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 255 deletions.
8 changes: 2 additions & 6 deletions Config.sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
'db_connection_string': 'mysql+mysqlconnector://shortenurl:Taj0moV2Ab0Wyb6I@localhost/shorturl',
'add_quota_per': 300,
'offset': 0,
'API_URL': 'https://api.mailgun.net/v3',
'API_KEY': '',
'DOMAIN': '',
'SENDER': '',
'secret': '',
'BASE_PATH': os.path.dirname(os.path.realpath(__file__))
'BASE_PATH': os.path.dirname(os.path.realpath(__file__)),
'domain': 'https://nycu.one/'
}
26 changes: 2 additions & 24 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys

import ntust_me_mail as MailS
import short_url
import Helper

Expand Down Expand Up @@ -88,7 +87,7 @@ def add():
db.session.add(Visit(request.environ['REMOTE_ADDR'], 'add'))
db.session.commit()

return jsonify({'url': request.url_root + key})
return jsonify({'url': config['domain'] + key})

@app.route('/<key>', methods=['GET'])
def go(key):
Expand All @@ -99,28 +98,7 @@ def go(key):
db.session.add(Visit(request.environ['REMOTE_ADDR'], 'go'))
db.session.commit()

return redirect(result.url), 200

@app.route('/email/verify', methods=['GET'])
def email_verify():
applier = Email_Apply.query.get(request.args['token'])

if applier == None:
return render_template('email_service_verify.html', message='申請失敗,請聯繫 [email protected]')
else:
password = MailS.get_random_password(12)

MailS.add_smtp_credentials(applier.username, password)
MailS.add_forward_route(applier.username, applier.email)

email = applier.username + '@' + config['DOMAIN']

MailS.send_mail(email, 'NTUST.ME 電子信箱申請成功通知信', 'success_mail.html', data = {'name': applier.realname, 'email_address': email, 'password': password})

db.session.delete(applier)
db.session.commit()

return render_template('email_service_verify.html', message='申請成功,請檢視信箱,會有相關使用資訊')
return redirect(result.url)

if __name__ == '__main__':
if sys.argv[1] == 'init':
Expand Down
93 changes: 0 additions & 93 deletions ntust_me_mail.py

This file was deleted.

23 changes: 15 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
Flask==0.10.1
Flask-SQLAlchemy==2.1
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
click==8.0.3
dataclasses==0.8
Flask==2.0.2
Flask-SQLAlchemy==2.5.1
greenlet==1.1.2
gunicorn==20.1.0
importlib-metadata==4.8.1
itsdangerous==2.0.1
Jinja2==3.0.2
MarkupSafe==2.0.1
mysql-connector-python==8.0.15
protobuf==3.18.1
requests==2.9.1
short-url==1.2.1
SQLAlchemy==1.0.11
Werkzeug==0.11.3
wheel==0.24.0
SQLAlchemy==1.4.25
typing-extensions==3.10.0.2
Werkzeug==2.0.2
zipp==3.6.0
10 changes: 0 additions & 10 deletions templates/email_service_verify.html

This file was deleted.

8 changes: 4 additions & 4 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>NTUST Shorten URL</title>
<title>NYCU Shorten URL</title>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
Expand Down Expand Up @@ -82,7 +82,7 @@
<div id="content">
<h2>Hi</h2>
<p>
這是台科人專屬的短網址服務,目前十分簡易,歡迎有志參與改善的朋友和<a target="_blank" href="https:http://www.facebook.com/linroex"></a>聯絡<br> 請在下方輸入要縮的網址,多行網址請換行。
這是 NYCU.ONE 短網址服務,目前十分簡易,歡迎有志參與改善的朋友和<a target="_blank" href="https://www.facebook.com/linroex"></a>聯絡<br> 請在下方輸入要縮的網址,多行網址請換行。
</p>
<br>
<div class="form-group">
Expand All @@ -105,10 +105,10 @@ <h2 id="result_title">轉換結果</h4>
<tbody id="result">
<tr>
<td>
<input type="text" class="form-control" value="http://www.ntust.edu.tw/">
<input type="text" class="form-control" value="http://www.nycu.edu.tw/">
</td>
<td>
<input type="text" class="form-control" value="https://ntust.me/nz5zz">
<input type="text" class="form-control" value="https://nycu.one/nz5zz">
<td>
</tr>
</tbody>
Expand Down
55 changes: 0 additions & 55 deletions templates/success_mail.html

This file was deleted.

Loading

0 comments on commit 581bef7

Please sign in to comment.