-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtibiaVIP.py
31 lines (25 loc) · 830 Bytes
/
tibiaVIP.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from flask import Flask, request, json
from html_getter import get_url
from character_parser import parse_single_char as parse_char
import datetime
import config
import sqlite3
# Configuration of the Flask App
DATABASE = '/tmp/tibiatest.db'
DEBUG = True
SECRET_KEY = 'some_secret_key'
app = Flask(__name__)
app.config.from_object(__name__)
tibia_url = 'https://secure.tibia.com/community/?subtopic=characters&name={0}'
def db_connect():
sqlite3.connect(app.config['DATABASE'])
@app.route('/get_character', methods=['GET','POST'])
def get_character_by_name():
char_arg = request.args['character']
char_html = get_url(tibia_url.format(char_arg.replace(" ", '+')))
char = parse_char(char_html)
char_json = json.dumps(char)
print(char_json)
return char_json
if __name__ == "__main__":
app.run()