summaryrefslogtreecommitdiff
path: root/py-fake-service/app/pixelated_user_agent.py
blob: 7cc49d48359208a63c871a4c3bcd3654c503618b (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from flask import Flask, request, Response, redirect

import json
import datetime
import requests

app = Flask(__name__, static_url_path='', static_folder='../../web-ui/app')
client = None
converter = None
account = None

def respond_json(entity):
    response = json.dumps(entity)
    return Response(response=response, mimetype="application/json")


@app.route('/mails', methods=['POST'])
def save_draft_or_send():
    return respond_json({'ident': 123})


@app.route('/mails', methods=['PUT'])
def update_draft():
    return respond_json({'ident': 123})


@app.route('/mails')
def mails():
    mails = []
    response = {
        "stats": {
            "total": len(mails),
            "read": 0,
            "starred": 0,
            "replied": 0
        },
        "mails": mails
    }

    return respond_json(response)


@app.route('/mail/<mail_id>', methods=['DELETE'])
def delete_mails(mail_id):
    return respond_json(None)


@app.route('/tags')
def tags():
    tags = []
    return respond_json(tags)


@app.route('/mail/<mail_id>')
def mail(mail_id):
    return respond_json({})


@app.route('/mail/<mail_id>/tags')
def mail_tags(mail_id):
    return respond_json([])


@app.route('/mail/<mail_id>/read', methods=['POST'])
def mark_mail_as_read(mail_id):
    return ""


@app.route('/contacts')
def contacts():
    return respond_json({'contacts': []})


@app.route('/draft_reply_for/<mail_id>')
def draft_reply_for(mail_id):
    return respond_json(None)


@app.route('/')
def index():
    return app.send_static_file('index.html')

def setup():
    app.config.from_envvar('PIXELATED_UA_CFG')
    provider = app.config['PROVIDER']
    account = app.config['ACCOUNT']

    app.run(host=app.config['HOST'], debug=app.config['DEBUG'], port=app.config['PORT'])

if __name__ == '__main__':
    setup()