-
Notifications
You must be signed in to change notification settings - Fork 12
Хмелев Дмитрий #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
NeSmogPridymatNick
wants to merge
3
commits into
pahaz:master
Choose a base branch
from
NeSmogPridymatNick:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Хмелев Дмитрий #14
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| __author__ = 'Acedia' | ||
|
|
||
| def readfile(): | ||
| f = open('date/text.txt', 'r') | ||
| str = "" | ||
| dict = [ | ||
| ] | ||
| while(str.find('end') < 0): | ||
| name = f.readline()[:-1] | ||
| comp = f.readline()[:-1] | ||
| tema = f.readline()[:-1] | ||
| text = "" | ||
| str = "" | ||
| while(str.find('--') < 0 and str.find('end') < 0): | ||
| str = f.readline() | ||
| if (str.find('--') < 0 and str.find('end') < 0): | ||
| str = str[:-1] | ||
| text += str | ||
| dict.append([name , comp, tema, text]) | ||
| return dict | ||
|
|
||
| def writefile(list): | ||
| f = open('date/text.txt', 'w') | ||
| for i in range(0, len(list)): | ||
| for j in range(0, len(list[i])): | ||
| f.writelines(list[i][j] +' \n') | ||
| if i == len(list) - 1: | ||
| f.writelines('end') | ||
| else: | ||
| f.writelines('-- \n') | ||
| return 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,85 @@ | ||
| from wsgiref.simple_server import make_server | ||
| from flask import Flask, jsonify, render_template, request | ||
| import datetime | ||
| import zapis | ||
| app = Flask(__name__) | ||
|
|
||
| __author__ = 'pahaz' | ||
| @app.template_filter() | ||
| def datetimefilter(value, format='%Y/%m/%d %H:%M'): | ||
| """convert a datetime to a different format.""" | ||
| return value.strftime(format) | ||
| id = 0 | ||
| app.jinja_env.filters['datetimefilter'] = datetimefilter | ||
| list = zapis.readfile() | ||
| @app.route("/") | ||
|
|
||
| def template_test(): | ||
| num = 0 | ||
| return render_template('template.html', num = num, | ||
| my_list=list, title="Index", current_time=datetime.datetime.now()) | ||
|
|
||
| def application(environ, start_response): | ||
| assert environ.get('PATH_INFO') is not None, "environ['PATH_INFO'] is None" | ||
| @app.route('/', methods = ['POST']) | ||
| def contact(): | ||
| if request.form['submit'] == 'Add': | ||
| return ''' | ||
| <form method='POST'> | ||
|
|
||
| status = "200 OK" | ||
| headers = [('Content-type', 'text/html; charset=utf-8')] | ||
| body = """<!DOCTYPE html> | ||
| <h1>Example-mini-application</h1> | ||
| """ | ||
| <p><strong>Как вас зовут?</strong></p> | ||
| <p><input name='name' maxlength="25" type="text" size="40" value="Вася"></p> | ||
|
|
||
| start_response(status, headers) | ||
| return [body.encode('utf-8')] | ||
| <p><strong>Кто вас обидел?</strong></p> | ||
| <p><input name='comp' maxlength="25" type="text" size="40" value="Евросеть"></p> | ||
|
|
||
| <p><strong>Чем вас обидел?</strong></p> | ||
| <p><input name='tema' maxlength="25" type="text" size="40" value="Телефон отжали"></p> | ||
|
|
||
| def run(host='', port=31338): | ||
| print("It's work! Visit http://{host}:{port}/".format( | ||
| host=host or 'localhost', | ||
| port=port)) | ||
| httpd = make_server(host, port, application) | ||
| httpd.serve_forever() | ||
| <p><b>Оставте коментарий</b></p> | ||
| <p><textarea name="comment" type="text">Я очень зол!!!!!!</textarea></p> | ||
|
|
||
| <input type="submit" name="submit" value="Ok"> | ||
| <input type="submit" name="submit" value="Close"> | ||
|
|
||
| if __name__ == "__main__": | ||
| run() | ||
| </form> | ||
| ''' | ||
| if request.form['submit'] == 'Ok': | ||
| text = [request.form['name'], request.form['comp'], request.form['tema'], request.form['comment']] | ||
| list.append(text) | ||
| zapis.writefile(list) | ||
| return template_test() | ||
| if request.form['submit'] == 'Delete': | ||
| global id | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. зарезервированное имя |
||
| id = int(request.form['index']) | ||
| list.pop(id - 1) | ||
| return template_test() | ||
| if request.form['submit'] == 'Refactor': | ||
| global id | ||
| id = int(request.form['index']) | ||
| form = "" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ад! шаблоны! |
||
| form += "<form method='POST'>" | ||
| form += "<p><strong>Как вас зовут?</strong></p>" | ||
| form += "<p><input name='name' maxlength='35' type='text' size='40' value=" + list[id-1][0] + "></p>" | ||
|
|
||
| form += "<p><strong>Кто вас обидел?</strong></p>" | ||
| form += "<p><input name='comp' maxlength='35' type='text' size='40' value=" + list[id-1][1] + "></p>" | ||
|
|
||
| form += "<p><strong>Чем вас обидел?</strong></p>" | ||
| form += "<p><input name='tema' maxlength='35' type='text' size='40' value=" + list[id-1][2] + "></p>" | ||
|
|
||
| form += "<p><b>Оставте коментарий</b></p>" | ||
| form += "<p><textarea name='comment' type='text'>" + list[id-1][3] + "</textarea></p>" | ||
|
|
||
| form += "<input type='submit' name='submit' value='Refresh'>" | ||
| form += "<input type='submit' name='submit' value='Censel'>" | ||
|
|
||
| form += "</form>" | ||
| return form | ||
| if request.form['submit'] == 'Refresh': | ||
| list[id - 1][0] = request.form['name'] | ||
| list[id - 1][1] = request.form['comp'] | ||
| list[id - 1][2] = request.form['tema'] | ||
| list[id - 1][3] = request.form['comment'] | ||
| zapis.writefile(list) | ||
| return template_test() | ||
| if request.form['submit'] == 'Censel': | ||
| return template_test() | ||
| if __name__ == '__main__': | ||
| app.run(debug=True) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <style> | ||
| .ID{ | ||
| visibility: hidden; | ||
| } | ||
| </style> | ||
| <h3>Здесь вы можите оставить свой отрицательный отзыв</h3> | ||
| <br> | ||
| <form method="post"> | ||
| <ul> | ||
| {% for n in my_list %} | ||
| <form method="post"> | ||
| <li> | ||
| {% set num = num + 1 %} | ||
| {{n[0]}}<br> | ||
| {{n[1]}}<br> | ||
| {{n[2]}}<br> | ||
| {{n[3]}}<br> | ||
| </li> | ||
| <input type="submit" name="submit" value="Refactor"> | ||
| <input type="submit" name="submit" value="Delete"> | ||
| <input class = 'ID' name='index' maxlength="5" type="text" size="40" value={{num}}> | ||
| </form> | ||
| {% endfor %} | ||
| </ul> | ||
| </form> | ||
| <br> | ||
| <form method="POST"> | ||
| <input type="submit" name="submit" value="Add"> | ||
| </form> | ||
| <br> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Шаблоны же :)